-
May 20th, 2009, 05:05 AM
#1
[RESOLVED] VBA Access Macro to Print Word Document
Hey guys!
I have an Access 2003 database. In this database we input start dates for when a student starts with a certain course, and end dates. What I want to do ( to make my life so much easier ) is to write a Macro to automatically print that particular subject's Exam.
The Macros Option Access provides are not very helpful here. So, I decided to write the VBA code inside a module. The code I wrote was this :
Code:
Public Sub RunWordMacroOrSub()
'Check Tools/Reference Microsoft Word Object Library
'declare variables
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
'Word application stuff
Set wdApp = New Word.Application
wdApp.Visible = False
Set wdDoc = wdApp.Documents.Open("Blah Blah Blah.doc")
wdDoc.PrintOut
'done
wdApp.Quit
Set wdDoc = Nothing
Set wdApp = Nothing
End Sub
Problem now is, How do I Run / execute this code from an Access Macro ¿
I have tried the RunCode option like this :
Code:
Modules![Test1]!RunWordMacroOrSub
Nothing happens, not even an error.
Does anyone have any idea what I did wrong, or can anyone suggest a better way to print a Word document from Access ¿
Any help would be greatly appreciated.
Hannes
-
May 20th, 2009, 08:54 AM
#2
Re: VBA Access Macro to Print Word Document
-
May 20th, 2009, 09:22 AM
#3
Re: [RESOLVED] VBA Access Macro to Print Word Document
Opps, I was late. I was actually previewing the post (reply) when i noticed it has been resolved. Anyway I suggested a commandbutton ...
Code:
Private Sub Command0_Click()
RunWordMacroOrSub
End Sub
Yes youre right in what you have discovered. This "Modules![Test1]!RunWordMacroOrSub" will run Macro but not a VBA sub (which you have converted to).
Marketing our skills - please participate in the survey and share your insights
-
-
May 20th, 2009, 09:35 AM
#4
Re: [RESOLVED] VBA Access Macro to Print Word Document
Thanx anyways for your efforts!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|