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 / February 2005

Tip: Looking for answers? Try searching our database.

Starting MS Word 2002 from VB script

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Randy - 10 Feb 2005 20:59 GMT
I can start Word ok, just cannot get a blank document to come up,  so when my
script runs it gets an error because it expects a blank Doc to be up.  

Here is what I am doing -

Dim WordApplication As Object
    Dim WordApp As Object

    ' Add four additional steps for initialization and post processing
    OpenCancelDialog "Opening Microsoft Word", ReportOptions.TotalClasses + 4

    StepCancelDialog "Opening Microsoft Word", 0

    'GSB Fix exception error handling
    ' If an error occurs then go to the TryWord95Create label
    ' On Error GoTo TryWord95Create XXX revalid

    ' Create an instance of Word using Word 97 technique
    Set WordApplication = CreateObject ("Word.Application")
    Set WordApp = WordApplication.WordBasic
    GoTo HaveWordApp

TryWord95Create:
    'GSB Fix exception error handling
    ' If an error occurs then go to the CancelPressed label
    ' On Error GoTo CancelPressed XXX revalid

    ' Create an instance of Word using Word 95 technique
    Set WordApp = CreateObject ("Word.Basic")

HaveWordApp:
    ' If an error occurs then go to the CancelPressed label
    ' On Error GoTo CancelPressed XXX revalid

    StepCancelDialog "Loading Document Template", 1
     ' WordApp.FileNew TemplatePathName$
    WordApp.FileNew    
    SubStepCancelDialog
      ' WordApp.FileSaveAs FileName$
Doug Robbins - 11 Feb 2005 00:01 GMT
Don't know why you are setting WordApp to WordApplication.WordBasic, but to
create a new document, use

WordApplication.Documents.Add

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

>I can start Word ok, just cannot get a blank document to come up,  so when
>my
[quoted text clipped - 36 lines]
> SubStepCancelDialog
>    ' WordApp.FileSaveAs FileName$
Randy - 11 Feb 2005 13:57 GMT
That did not work, got a run-time error -2147417851 (0x80010105) on the line
with 'WordApplication.Documents.Add'.

> Don't know why you are setting WordApp to WordApplication.WordBasic, but to
> create a new document, use
[quoted text clipped - 41 lines]
> > SubStepCancelDialog
> >    ' WordApp.FileSaveAs FileName$
Doug Robbins - 12 Feb 2005 00:33 GMT
Did you have that after Set WordApplication = CreateObject
("Word.Application")?

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> That did not work, got a run-time error -2147417851 (0x80010105) on the
> line
[quoted text clipped - 48 lines]
>> > SubStepCancelDialog
>> >    ' WordApp.FileSaveAs FileName$
Randy - 14 Feb 2005 14:09 GMT
Yes, here is part of my script -

    Dim WordApplication As Object
    Dim WordApp As Object

    ' Add four additional steps for initialization and post processing
    OpenCancelDialog "Opening Microsoft Word", ReportOptions.TotalClasses + 4

    StepCancelDialog "Opening Microsoft Word", 0

    'GSB Fix exception error handling
    ' If an error occurs then go to the TryWord95Create label
    ' On Error GoTo TryWord95Create XXX revalid

    ' Create an instance of Word using Word 97 technique
    Set WordApplication = CreateObject ("Word.Application")
    Set WordApp = WordApplication.WordBasic
    GoTo HaveWordApp

TryWord95Create:
    'GSB Fix exception error handling
    ' If an error occurs then go to the CancelPressed label
    ' On Error GoTo CancelPressed XXX revalid

    ' Create an instance of Word using Word 95 technique
    Set WordApp = CreateObject ("Word.Basic")

HaveWordApp:
    ' If an error occurs then go to the CancelPressed label
    ' On Error GoTo CancelPressed XXX revalid

    StepCancelDialog "Loading Document Template", 1
     ' WordApp.FileNew TemplatePathName$ commented out by R. Bootes
    WordApp.FileNew     ' added by Randy Bootes
    SubStepCancelDialog
      ' WordApp.FileSaveAs FileName$ ' Commented out by Randy Bootes

> Did you have that after Set WordApplication = CreateObject
> ("Word.Application")?
[quoted text clipped - 51 lines]
> >> > SubStepCancelDialog
> >> >    ' WordApp.FileSaveAs FileName$
Doug Robbins - 15 Feb 2005 02:00 GMT
I don't see (nor does Word's Edit>Find) "WordApplication.Documents.Add"
anywhere in your code.

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Yes, here is part of my script -
>
[quoted text clipped - 91 lines]
>> >> > SubStepCancelDialog
>> >> >    ' WordApp.FileSaveAs FileName$
 
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.