Click here to Skip to main content
       

C#

 
GeneralRe: Copy username from text file to website PinmentorDaveyM6928-Feb-13 10:30 
GeneralRe: Copy username from text file to website PinmemberMuhammad Sayyam2-Mar-13 20:19 
GeneralRe: Copy username from text file to website PinmentorDaveyM695-Mar-13 3:08 
GeneralRe: Copy username from text file to website PinmentorDaveyM697-Mar-13 21:51 
Questiontooth numbers PinmemberJassim Rahma28-Feb-13 0:35 
AnswerRe: tooth numbers PinprotectorPete O'Hanlon28-Feb-13 1:11 
AnswerRe: tooth numbers PinmemberGuyThiebaut28-Feb-13 2:03 
QuestionVS2012, C# Office 2007 problem PinmemberDaytona67527-Feb-13 9: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 PinmvpRichard MacCutchan27-Feb-13 21:58 
AnswerRe: VS2012, C# Office 2007 problem PinmvpOriginalGriff27-Feb-13 22:40 
Questionc# field type is less accessible than field (SOLVED!) [modified] Pinmemberjojoba201127-Feb-13 9:25 
AnswerRe: c# field type is less accessible than field PinmemberJibesh27-Feb-13 9:39 
AnswerRe: c# field type is less accessible than field PinmemberRichard Deeming27-Feb-13 9:41 
AnswerRe: c# field type is less accessible than field PinmemberMatt T Heffron27-Feb-13 9:49 
Question[DllImport("NetApi32.dll"... throws exception for first few times Pinmembershoab.shah26-Feb-13 20:04 
AnswerRe: [DllImport("NetApi32.dll"... throws exception for first few times PinmvpRichard MacCutchan26-Feb-13 22:33 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pinmembershoab.shah26-Feb-13 23:20 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times PinmvpRichard MacCutchan26-Feb-13 23:37 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times PinprotectorPete O'Hanlon26-Feb-13 23:46 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pinmembershoab.shah27-Feb-13 0:12 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times PinprotectorPete O'Hanlon27-Feb-13 0:15 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pinmembershoab.shah27-Feb-13 0:18 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times PinprotectorPete O'Hanlon27-Feb-13 0:32 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pinmembershoab.shah27-Feb-13 1:07 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times PinmvpRichard MacCutchan27-Feb-13 3:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web01 | 2.8.140721.1 | Last Updated 31 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid