Closing Word from Access

Noreene Patrick

Registered User.
Local time
Yesterday, 22:45
Joined
Jul 18, 2002
Messages
223
In my database, I have a macro that outputs a report to our server in rtf format...the output works fine, but it shows me a preview of the report in Word and I have to manually close the Word application each time...This is for many users on our server so I dont want them to have to close this application themselves.

I have searched the forum and come up with some answers but none seem to work unless I am just not putting the code in the correct place, maybe.

How can I just tell it to close the Word application...?

Thanks, Noreene
 
Hi

This code outputs the report without showing the document.

PHP:
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

    Dim stDocName As String

    stDocName = "FORUM_BADWORDS"
    DoCmd.OutputTo acReport, stDocName, ".rtf", stDocName & ".rtf", False

Exit_Command6_Click:
    Exit Sub

Err_Command6_Click:
    MsgBox Err.Description
    Resume Exit_Command6_Click
    
End Sub



The argument False stops the word document opening, i'm not sure what you do in a macro, sorry.


Chris
 
Thank you for that code, Chris.

But, I dont know where to put the code since I already have my macro tested and running correctly...if I change everything I am afraid of messing up what I have already...

Can I get some ideas?

Thanks, Noreene
 
Hi


I just had a look at the outputto macro procedure and under autostart select no that stops the report opening up in word.

Chris
 
Create a new Button, and chose [cancel] to the window that apears(assuming it is displayed)

Right click on the control, then chose [Build event] and use the code builder option, all you have to do then is cut and paste CJBIRKIN's code.


[edit] or just do it in the macro as CJBIRKIN just posted [/edit]

:cool:ShadeZ:cool:
 
THAT WORKED GREAT!!!!!! thanks to both of you for your help...

I LOVE THIS FORUM!!
 

Users who are viewing this thread

Back
Top Bottom