Hello Marc
I am not exact about the following points. Would you help to confirm them
so that I could have a clearer picture of the issue?
For one thing, I activate each excel graph as you suggested by sending it
a "Hide" via doVerb. I then go and stick values in the table, then cut
the object and paste it in the report. I send it another Hide at the end
of the chart update (hoping that this would get stuck until Excel was
actually done.)
How did you stick values and cut/paste object in the report? Are they done
with automation or manually? In your last message, I notice that the
application throws an exception at Application.Selection. Would you let me
know where the Application.Selection is called? Would you paste some code
here to show the process of the operation?
I modified the test code that I posted last time, add
application.Selection.Copy() in the end, and it works well in my side:
object missing = Type.Missing;
object filename = "file name";
Word.Application application = new
Microsoft.Office.Interop.Word.Application();
application.Visible = true;
Word.Document document = application.Documents.Open(ref
filename, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing);
Word.InlineShape wrdInlineShape = document.InlineShapes[1];
if (wrdInlineShape.OLEFormat.ProgID == "Excel.Chart.8")
{
// Word doesn't keep all of its embedded objects in the
running state all the time.
// In order to access the interface you first have to
ensure the object is in the running state,
// ie: OLEFormat.Activate() (or something)
object verb = Word.WdOLEVerb.wdOLEVerbHide;
wrdInlineShape.OLEFormat.DoVerb(ref verb);
Excel.Workbook obook =
(Excel.Workbook)wrdInlineShape.OLEFormat.Object;
Excel.Worksheet sheet =
(Excel.Worksheet)obook.Worksheets["Sheet1"];
Excel.Range range = (Excel.Range)sheet.Cells[1, 1];
range.Value2 = "just for test";
}
Console.Read(); // at this point, I select the chart manually in word
application.Selection.Copy()
// quit the word
System.Xml.XPath.XPathException was unhandled
Message="Function 'qib:questOfIntComplete()' has failed."
Source="WordApp"
What is the qid:quesstionOfIntComplete()? Is it a user defined function in
Excel?
Now, for your questions:
Are my calls to Word/Excel synchronous? That is, are these apps
finished doing what I told them to when they return to me?
Yes, it is synchronous. When the method returns, the operation is done.
Is there a proper protocol for knowing when Word/Excel are idle, ready
for work, or finished with the last command?
As far as I know, Word object model does not expose a method for busy
status. See also:
http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=m
icrosoft.public.word.vba.addins&tid=fa0f62d4-ea9d-49d9-9c4d-702796d2ea5a&p=1
Generally speaking, Work is in busy state when there is displaying a
message box. Word will not accept external communication when it is showing
a modal dialog.
As an alternative to Excel.Chart, I might be able to us MSGraph.Chart,
but I can't find any documentation for this class in my VS2005 or Office
developer docs. Does MSGraph expose its API? If so, where is the
documentation and how do I get VS to know about the classes? Is MSGraph
still part of Office? If so, it's probably safer to use it than having to juggle
Excel and Word together.
To use MSGraph, we need to reference Microsoft Graph *.* Object library.
Here are some KB articles about how to edit an MS graph Object
programmatically:
http://support.microsoft.com/kb/190239
http://support.microsoft.com/kb/244589
The complete introduction of Microsoft Graph object model can be found at
http://msdn2.microsoft.com/en-us/library/Aa198537(office.10).aspx
Regards
Jialiang Ge (
[email protected], remove 'online.')
Microsoft Online Community Support
=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.