Answered by:
Application Object... need some help

Question
-
Hi,
I am using Office integration pack as demonstrated by Beth Massi here (http://blogs.msdn.com/b/bethmassi/archive/2011/09/22/fun-with-the-office-integration-pack-extension-for-lightswitch.aspx).
- I will need some help in order to <Quit Word without saving> after opening and printing the generated document.
I succesfuly found the way to print directly after opening the document using the following code:
word.Application.PrintOut()
Following are some references but i will need some help to understand by providing some example code how to use these objects as i am new to this
- options object http://msdn.microsoft.com/en-us/library/aa192495(v=office.11).aspx#wordobject_link
- application object http://msdn.microsoft.com/en-us/library/aa221371(v=office.11).aspx
Thanks!
Wednesday, February 15, 2012 6:41 AM
Answers
-
I can't find the documentation for it, but the first argument for the Close method on Document objects seems to be a notion of "save changes". So doing this:
doc.Close(True)
will save the document and close it.Justin Anderson, LightSwitch Development Team
- Proposed as answer by Spursoft Solutions Wednesday, February 15, 2012 2:36 PM
- Marked as answer by tsiakk Wednesday, February 15, 2012 3:59 PM
Wednesday, February 15, 2012 12:46 PMModerator
All replies
-
The first link (options link) describes how to close documents and Word itself under the Closing Documents section.
Justin Anderson, LightSwitch Development Team
Wednesday, February 15, 2012 8:01 AMModerator -
Hi..I am trying the following commands but i am getting the error { Error while invoking WdSaveOptions - member not found. } .Can you please help fix it ? If i try doc.Close() it works okay, but if i want to : Close all documentsa and save with no prompt it does not.
Dim word_application_obj As Object = Nothing word_application_obj = OfficeIntegration.Word.GetWord() 'returns Word.Application Object
....
Dim doc As Object doc = OfficeIntegration.Word.GenerateDocument(WordFile, PRESCRIPTIONS.SelectedItem, mappingsprescription) 'returns Word.Document object
....
doc.Close(word_application_obj.WdSaveOptions.wdSaveChanges) 'Error while invoking WdSaveOptions - member not found.
Wednesday, February 15, 2012 10:41 AM -
I can't find the documentation for it, but the first argument for the Close method on Document objects seems to be a notion of "save changes". So doing this:
doc.Close(True)
will save the document and close it.Justin Anderson, LightSwitch Development Team
- Proposed as answer by Spursoft Solutions Wednesday, February 15, 2012 2:36 PM
- Marked as answer by tsiakk Wednesday, February 15, 2012 3:59 PM
Wednesday, February 15, 2012 12:46 PMModerator -
thanks !that worked... the only problem is that the Document after the document is closedn an empty instance of MSWORD window stays open and the user has to close it manually.is that normal?
what do you sugest? thanks
Wednesday, February 15, 2012 7:22 PM