Click here to Skip to main content
15,880,796 members
Home / Discussions / C#
   

C#

 
GeneralRe: Copy username from text file to website Pin
DaveyM6928-Feb-13 10:30
professionalDaveyM6928-Feb-13 10:30 
GeneralRe: Copy username from text file to website Pin
Muhammad Sayyam2-Mar-13 20:19
Muhammad Sayyam2-Mar-13 20:19 
GeneralRe: Copy username from text file to website Pin
DaveyM695-Mar-13 3:08
professionalDaveyM695-Mar-13 3:08 
GeneralRe: Copy username from text file to website Pin
DaveyM697-Mar-13 21:51
professionalDaveyM697-Mar-13 21:51 
Questiontooth numbers Pin
Jassim Rahma28-Feb-13 0:35
Jassim Rahma28-Feb-13 0:35 
AnswerRe: tooth numbers PinPopular
Pete O'Hanlon28-Feb-13 1:11
mvePete O'Hanlon28-Feb-13 1:11 
AnswerRe: tooth numbers Pin
GuyThiebaut28-Feb-13 2:03
professionalGuyThiebaut28-Feb-13 2:03 
QuestionVS2012, C# Office 2007 problem Pin
Daytona67527-Feb-13 9:34
Daytona67527-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 Pin
Richard MacCutchan27-Feb-13 21:58
mveRichard MacCutchan27-Feb-13 21:58 
AnswerRe: VS2012, C# Office 2007 problem Pin
OriginalGriff27-Feb-13 22:40
mveOriginalGriff27-Feb-13 22:40 
Questionc# field type is less accessible than field (SOLVED!) Pin
jojoba201127-Feb-13 9:25
jojoba201127-Feb-13 9:25 
AnswerRe: c# field type is less accessible than field Pin
Jibesh27-Feb-13 9:39
professionalJibesh27-Feb-13 9:39 
AnswerRe: c# field type is less accessible than field PinPopular
Richard Deeming27-Feb-13 9:41
mveRichard Deeming27-Feb-13 9:41 
AnswerRe: c# field type is less accessible than field Pin
Matt T Heffron27-Feb-13 9:49
professionalMatt T Heffron27-Feb-13 9:49 
Question[DllImport("NetApi32.dll"... throws exception for first few times Pin
shoab.shah26-Feb-13 20:04
shoab.shah26-Feb-13 20:04 
AnswerRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Richard MacCutchan26-Feb-13 22:33
mveRichard MacCutchan26-Feb-13 22:33 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
shoab.shah26-Feb-13 23:20
shoab.shah26-Feb-13 23:20 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Richard MacCutchan26-Feb-13 23:37
mveRichard MacCutchan26-Feb-13 23:37 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Pete O'Hanlon26-Feb-13 23:46
mvePete O'Hanlon26-Feb-13 23:46 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
shoab.shah27-Feb-13 0:12
shoab.shah27-Feb-13 0:12 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Pete O'Hanlon27-Feb-13 0:15
mvePete O'Hanlon27-Feb-13 0:15 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
shoab.shah27-Feb-13 0:18
shoab.shah27-Feb-13 0:18 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Pete O'Hanlon27-Feb-13 0:32
mvePete O'Hanlon27-Feb-13 0:32 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
shoab.shah27-Feb-13 1:07
shoab.shah27-Feb-13 1:07 
GeneralRe: [DllImport("NetApi32.dll"... throws exception for first few times Pin
Richard MacCutchan27-Feb-13 3:46
mveRichard MacCutchan27-Feb-13 3: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.