Hi,
Version (Access): 2003
Version (Word): 2003
Wanted to know if it is possible to run a word macro from a button on my access form that opens the word document.
I have got this code currently (on the access form) - i can open the document correctly by using this code:
Private Sub IWS_Print_Button_Click()
On Error GoTo Err_IWS_Print_Button__Click
Dim objword As Object
Set objword = CreateObject("Word.Application")
objword.Visible = True
objword.Documents.Open ("C:\Documents and Settings\Neil\My Documents\sad.doc")
Exit_IWS_Print_Button__Click:
Exit Sub
Err_IWS_Print_Button__Click:
MsgBox Err.Description, , "User Request"
Resume Exit_IWS_Print_Button__Click
End Sub
However, i want to be able to run the word macro code (shown below) automatically after opening the document, in order to print it - unless there is some code that already enables me to do this that i have missed.
Could all you brill people help by telling me where the code should go and any extra lines that i need to add to the above code.
This is the macro code that i want to run upon opening the document:
Sub Printing()
'
' Printing Macro
' Macro recorded 31/08/2009 by Neil
'
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=False, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End Sub
Version (Access): 2003
Version (Word): 2003
Wanted to know if it is possible to run a word macro from a button on my access form that opens the word document.
I have got this code currently (on the access form) - i can open the document correctly by using this code:
Private Sub IWS_Print_Button_Click()
On Error GoTo Err_IWS_Print_Button__Click
Dim objword As Object
Set objword = CreateObject("Word.Application")
objword.Visible = True
objword.Documents.Open ("C:\Documents and Settings\Neil\My Documents\sad.doc")
Exit_IWS_Print_Button__Click:
Exit Sub
Err_IWS_Print_Button__Click:
MsgBox Err.Description, , "User Request"
Resume Exit_IWS_Print_Button__Click
End Sub
However, i want to be able to run the word macro code (shown below) automatically after opening the document, in order to print it - unless there is some code that already enables me to do this that i have missed.
Could all you brill people help by telling me where the code should go and any extra lines that i need to add to the above code.
This is the macro code that i want to run upon opening the document:
Sub Printing()
'
' Printing Macro
' Macro recorded 31/08/2009 by Neil
'
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=False, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End Sub