Closing Word97 from Access97 
Author Message
 Closing Word97 from Access97

I've got the following routine within an Access97 database which does not
work properly. What I want to do is:

a) printing and closing the Word97 document created upon the template
without saving it and

b) closing the Word97 application finally.

What is the correct code for that? I get errors on
"Range:=wdPrintAllDocument" (I could leave that code away) and
"SaveChanges:=wdDoNotSaveChanges", which seems not to be understood by
Access97.

Thanks in advance,
Hans van Gelder

    Set objWordApp = CreateObject("Word.Application")
        With objWordApp
            .Visible = True

            .Documents.Add Template:="C:\directory\template.dot",
NewTemplate:=False

            .ActiveDocument.Bookmarks("Bookmark").Select
            .Selection.TypeText Forms![Form]![txtTextfield].Value

            .ActiveDocument.PrintOut Range:=wdPrintAllDocument

            .ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

        End With
    AppActivate "Microsoft Word", False

    Set objWordApp = Nothing



Sun, 14 Sep 2003 03:40:12 GMT  
 Closing Word97 from Access97
The first problem a) has been solved, just by adding:

Dim wdPrintAllDocument As Integer
Dim wdDoNotSaveChanges As Integer

However, quiting Word by .Quit at the end of the With-End With routine still
results in an error.



Quote:
> I've got the following routine within an Access97 database which does not
> work properly. What I want to do is:

> a) printing and closing the Word97 document created upon the template
> without saving it and

> b) closing the Word97 application finally.

> What is the correct code for that? I get errors on
> "Range:=wdPrintAllDocument" (I could leave that code away) and
> "SaveChanges:=wdDoNotSaveChanges", which seems not to be understood by
> Access97.

> Thanks in advance,
> Hans van Gelder

>     Set objWordApp = CreateObject("Word.Application")
>         With objWordApp
>             .Visible = True

>             .Documents.Add Template:="C:\directory\template.dot",
> NewTemplate:=False

>             .ActiveDocument.Bookmarks("Bookmark").Select
>             .Selection.TypeText Forms![Form]![txtTextfield].Value

>             .ActiveDocument.PrintOut Range:=wdPrintAllDocument

>             .ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

               .Quit

- Show quoted text -

Quote:

>         End With
>     AppActivate "Microsoft Word", False

>     Set objWordApp = Nothing



Sun, 14 Sep 2003 05:12:51 GMT  
 Closing Word97 from Access97
My second problem b) has been solved now too. The code works as below. If
there is a better way please let me know.

Regards,
Hans van Gelder

----------
Dim objWordApp As Object
Dim wdDoNotSaveChanges As Integer
Dim wdPrintAllDocument As Integer

    Set objWordApp = CreateObject("Word.Application")
        With objWordApp
            .Visible = True

            .Documents.Add Template:="C:\directory\template.dot",
NewTemplate:=False

            .ActiveDocument.Bookmarks("Bookmark").Select
            .Selection.TypeText Forms![Form]![txtTextfield].Value

            .ActiveDocument.PrintOut Range:=wdPrintAllDocument

            .ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

        End With
    AppActivate "Microsoft Word", False

        With objWordApp
            .Quit
        End With

    Set objWordApp = Nothing
----------



Quote:
> The first problem a) has been solved, just by adding:

> Dim wdPrintAllDocument As Integer
> Dim wdDoNotSaveChanges As Integer

> However, quiting Word by .Quit at the end of the With-End With routine
still
> results in an error.



> > I've got the following routine within an Access97 database which does
not
> > work properly. What I want to do is:

> > a) printing and closing the Word97 document created upon the template
> > without saving it and

> > b) closing the Word97 application finally.

> > What is the correct code for that? I get errors on
> > "Range:=wdPrintAllDocument" (I could leave that code away) and
> > "SaveChanges:=wdDoNotSaveChanges", which seems not to be understood by
> > Access97.

> > Thanks in advance,
> > Hans van Gelder

> >     Set objWordApp = CreateObject("Word.Application")
> >         With objWordApp
> >             .Visible = True

> >             .Documents.Add Template:="C:\directory\template.dot",
> > NewTemplate:=False

> >             .ActiveDocument.Bookmarks("Bookmark").Select
> >             .Selection.TypeText Forms![Form]![txtTextfield].Value

> >             .ActiveDocument.PrintOut Range:=wdPrintAllDocument

> >             .ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

>                .Quit

> >         End With
> >     AppActivate "Microsoft Word", False

> >     Set objWordApp = Nothing



Sun, 14 Sep 2003 05:31:55 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Closing Word97 from Access97

2. Pulling Access97 data into Word97 variables

3. Editing an Access97 field value from Word97

4. Access97-Word97 Mail Merge

5. Access97/Word97/data exchange HELP!!!

6. Access97/Word97 MailMerge

7. Linking Access97 and Word97

8. passing values between Word97 and Access97

9. Mail Merge access97 with word97 (Blank spaces)

10. Access97 and Word97 (MailMerge)

11. DDE between Access97 and Word97

12. Integration between Access97 and Word97

 

 
Powered by phpBB® Forum Software