Hi,
I am trying to call the following function in a code module from a command button on a form:
I cannot work out how to run this by pressing a command button, nothing seems to work. I do not want to pass anything to it just run it as is.
I have looked around and it is suggested that just PrintDoc() should work but it is asking for a macro name :s
Any help please?
I am trying to call the following function in a code module from a command button on a form:
Code:
Function PrintDoc()
Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open "C:\Project v0.1\PrintForm.docx"
WordObj.PrintOut Background:=False
WordObj.Quit
Set WordObj = Nothing
End Function
I cannot work out how to run this by pressing a command button, nothing seems to work. I do not want to pass anything to it just run it as is.
I have looked around and it is suggested that just PrintDoc() should work but it is asking for a macro name :s
Any help please?