Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

"Phantom" window

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
edger - 02 Nov 2005 00:46 GMT
I have a VBScript script that processes text files into both Word and Excel
documents. The script runs macros that I have written in a document and
workbook called WordMacros.doc and ExcelMacros.xls. The script reads
instructions from text files, opens the document or workbook as required, and
runs the appropriate macro to do the processing.

This works fine, but at the conclusion of the processing, an extraneous
(empty)Word window opens. I've tried all sequences of opening and closing
Word that I can think of, but nothing seems to prevent this.

Set appWord = CreateObject("Word.Application")
appWord.Visible = False
appWord.Documents.Open(WordMacros)
    ...
    ...
appWord.Documents.Close()

Doing the Open and Close just once each doesn't work and neither does doing
them before and after each macro. I've tried closing and not closing the
newly-created document within each macro.

Any ideas???
Tony Jollans - 02 Nov 2005 00:52 GMT
Hi Edger,

As well as closing the document, you need to quit the application and, as
good practice if nothing else, release the object variable ...

Set appWord = CreateObject("Word.Application")
appWord.Visible = False
appWord.Documents.Open(WordMacros)
    ...
    ...
appWord.Documents.Close()
appWord.Quit
Set appWord = Nothing

--
Enjoy,
Tony

> I have a VBScript script that processes text files into both Word and Excel
> documents. The script runs macros that I have written in a document and
[quoted text clipped - 18 lines]
>
> Any ideas???
edger - 02 Nov 2005 01:57 GMT
Bless you, sir. That was driving me up the wall. Interestingly, a comparable
command is apparently unnecessary for Excel.
Edger

> Hi Edger,
>
[quoted text clipped - 39 lines]
> >
> > Any ideas???
Tony Jollans - 02 Nov 2005 02:16 GMT
Glad I could help.

You really should do exactly the same in Excel. At the very least it's good
practice. Even if what you have appears to be working at the moment (which
surprises me) it'll come back to haunt you sooner or later.

--
Enjoy,
Tony

> Bless you, sir. That was driving me up the wall. Interestingly, a comparable
> command is apparently unnecessary for Excel.
[quoted text clipped - 43 lines]
> > >
> > > Any ideas???
edger - 02 Nov 2005 15:40 GMT
Thanks, I'll add that to my script . It already releases both object
variables.
edger

> Glad I could help.
>
[quoted text clipped - 60 lines]
> > > >
> > > > Any ideas???

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.