Hiding MS Word Window

kumaraswamy

Member
Joined
Jul 24, 2009
Messages
12
Programming Experience
1-3
Thanks a lot! It helped.
I have another query -
I have the following lines:
Dim WordApp As New Microsoft.Office.Interop.Word.Application
Dim WordDoc As Microsoft.Office.Interop.Word.Document
.
.

WordApp.Visible = False
WordDoc = WordApp.Documents.Open(strFileName)
.
.

Dim WordDoc As Microsoft.Office.Interop.Word.Document
Thought WordApp.Visible is False, the word application opens. I dont want this to happen. I just want VB .NET to display the contents of the file in the label. IS there a way to suppress the opening of Word Document?

Thanks
Kumar
 
Actually, when I do Word automation I have to set Visible=True for it to display, default is hidden.
 
If you already figured this out, feel free to ignore this :)

When automating PPT & Excel, you put a 'WithWindow = False' after the file name that you are opening.

For example:

VB.NET:
 mainPres = app.Presentations.Open(FN_1_TITLE, WithWindow:=True)

I'm 99% sure that this is the same for the vast majority of Office products.

I hope this helps!
 
Only PP has a WithWindow parameter for Open method. Word has Visible parameter. Excel doesn't have any such parameter. I haven't tested what effect that would have with a hidden Word application, though.
 
If he's just reading a file and displaying the contents in a label, is there any specific need of automating Word?
 
Only PP has a WithWindow parameter for Open method. Word has Visible parameter. Excel doesn't have any such parameter. I haven't tested what effect that would have with a hidden Word application, though.

Looking back at my code, you're right...I have mainly worked with PPT - just dabbled in Excel. Thanks for clarifying!
 
Back
Top