Click here to Skip to main content
12,068,967 members (67,162 online)
   

C#

 
GeneralRe: Copy username from text file to website Pin
DaveyM6928-Feb-13 11:30
mentorDaveyM6928-Feb-13 11:30 
GeneralRe: Copy username from text file to website Pin
Muhammad Sayyam2-Mar-13 21:19
memberMuhammad Sayyam2-Mar-13 21:19 
GeneralRe: Copy username from text file to website Pin
DaveyM695-Mar-13 4:08
mentorDaveyM695-Mar-13 4:08 
GeneralRe: Copy username from text file to website Pin
DaveyM697-Mar-13 22:51
mentorDaveyM697-Mar-13 22:51 
Questiontooth numbers Pin
Jassim Rahma28-Feb-13 1:35
memberJassim Rahma28-Feb-13 1:35 
AnswerRe: tooth numbers Pin
Pete O'Hanlon28-Feb-13 2:11
protectorPete O'Hanlon28-Feb-13 2:11 
AnswerRe: tooth numbers Pin
GuyThiebaut28-Feb-13 3:03
memberGuyThiebaut28-Feb-13 3:03 
QuestionVS2012, C# Office 2007 problem Pin
Daytona67527-Feb-13 10:34
memberDaytona67527-Feb-13 10:34 
I've asked maybe to broad of a question before. So I have created a very simple application. My Word document has 1 chart in it.

In a nutshell, where is what happens:
1. Word Document is opened.
2. Find the number of Charts in the document.
3. Loop through the inline shapes
4. Check to see if they are Charts.

So as I said, nothing fancy.

private void Form1_Load(object sender, EventArgs e)
        {            
            Document oReportDoc = new Document();
            Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
            oReportDoc = oWord.Documents.Open(@"C:\ChartTest.docx", ReadOnly: false);
            label2.Text = oReportDoc.InlineShapes.Count.ToString();
            int j = 1;
            foreach (Microsoft.Office.Interop.Word.InlineShape wshape in oReportDoc.InlineShapes)
            {
                try
                {
                    if (wshape.OLEFormat.ProgID.Equals("Excel.Sheet.8"))
                    {
                        if (wshape.HasChart == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            wshape.OLEFormat.Open();
                            Microsoft.Office.Interop.Excel.Workbook xlWorkBook = wshape.OLEFormat.Object;
 
                            if (xlWorkBook != null)
                            {
                                xlWorkBook.ActiveChart.HasTitle = true;
                                xlWorkBook.ActiveChart.ChartTitle.Text = "test" + j.ToString() + "!";
                                j++;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    richTextBox1.Text = ex.Message;
                }
            }
        }


So it appears that, when debugging the code, that the OLEFormat property is Null, which I assume is causing the exception to fire off.

Can anyone tell me what is happening here and why the OLEFormat is null? And how to get around this issue?

Very frustrating.

Thanks,
Jeff
AnswerRe: VS2012, C# Office 2007 problem Pin
Richard MacCutchan27-Feb-13 22:58
mvpRichard MacCutchan27-Feb-13 22:58 
AnswerRe: VS2012, C# Office 2007 problem Pin
OriginalGriff27-Feb-13 23:40
mvpOriginalGriff27-Feb-13 23:40 
Questionc# field type is less accessible than field (SOLVED!) Pin
jojoba201127-Feb-13 10:25
memberjojoba201127-Feb-13 10:25 
AnswerRe: c# field type is less accessible than field Pin
Jibesh27-Feb-13 10:39
memberJibesh27-Feb-13 10:39 
AnswerRe: c# field type is less accessible than field Pin
Richard Deeming27-Feb-13 10:41
memberRichard Deeming27-Feb-13 10:41 
AnswerRe: c# field type is less accessible than field Pin
Matt T Heffron27-Feb-13 10:49
memberMatt T Heffron27-Feb-13 10:49 
Question[DllImport("NetApi32.dll"... throws exception for first few times Pin
shoab.shah26-Feb-13 21:04
membershoab.shah26-Feb-13 21:04 
AnswerRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Richard MacCutchan26-Feb-13 23:33
mvpRichard MacCutchan26-Feb-13 23:33 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
shoab.shah27-Feb-13 0:20
membershoab.shah27-Feb-13 0:20 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Richard MacCutchan27-Feb-13 0:37
mvpRichard MacCutchan27-Feb-13 0:37 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Pete O'Hanlon27-Feb-13 0:46
protectorPete O'Hanlon27-Feb-13 0:46 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
shoab.shah27-Feb-13 1:12
membershoab.shah27-Feb-13 1:12 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Pete O'Hanlon27-Feb-13 1:15
protectorPete O'Hanlon27-Feb-13 1:15 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
shoab.shah27-Feb-13 1:18
membershoab.shah27-Feb-13 1:18 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Pete O'Hanlon27-Feb-13 1:32
protectorPete O'Hanlon27-Feb-13 1:32 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
shoab.shah27-Feb-13 2:07
membershoab.shah27-Feb-13 2:07 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Richard MacCutchan27-Feb-13 4:46
mvpRichard MacCutchan27-Feb-13 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.160208.1 | Last Updated 9 Feb 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid