Open Word.doc from Access per fredg

  • Thread starter Thread starter Ken Curtis
  • Start date Start date
K

Ken Curtis

I noted script from fredg that showed how to print a Word.doc from an Access
command button. Very handy. It prompts a question: if I want to "open"
specific Word documents from an Access form do I just change the first line
of fredg's script to: Sub OpenWordDoc() ? or would it be easier just to
attach a hyperlink to the button?
 
i doubt that anyone wants to search the newsgroups high and low for the post
you're referring to. how about posting his code; probably somebody will be
able to answer, if fredg doesn't see this thread and reply.

hth
 
I'd be keen to see the original script as it might solve what I'm trying to
do myself. so could you please post the original script
 
please ignore my previous post, the fredg script was in answer to my query,
but the "notify me of replies didn't work".

his script is:

Sub PrintWordDoc()
On Error Resume Next
Dim objWord As Object
Dim objDoc As Object
Const wdPrintAllDocument = 0

Set objWord = CreateObject("Word.Application")
objWord.Visible = False

Set objDoc = objWord.Documents.Open("C:\Path to
Folder\YourDocName.doc")

objWord.ActiveDocument.PrintOut , _
Background:=False, _
Range:=wdPrintAllDocument
objDoc.Close False

Set objDoc = Nothing
objWord.Quit
Set objWord = Nothing

End Sub

regards
Bruce
 
thanks, Bruce :)


DRBE said:
please ignore my previous post, the fredg script was in answer to my query,
but the "notify me of replies didn't work".

his script is:

Sub PrintWordDoc()
On Error Resume Next
Dim objWord As Object
Dim objDoc As Object
Const wdPrintAllDocument = 0

Set objWord = CreateObject("Word.Application")
objWord.Visible = False

Set objDoc = objWord.Documents.Open("C:\Path to
Folder\YourDocName.doc")

objWord.ActiveDocument.PrintOut , _
Background:=False, _
Range:=wdPrintAllDocument
objDoc.Close False

Set objDoc = Nothing
objWord.Quit
Set objWord = Nothing

End Sub

regards
Bruce
 
having now seen the VBA code, posted by another user, i can at least
partially answer your question:
if I want to "open"
specific Word documents from an Access form do I just change the first line
of fredg's script to: Sub OpenWordDoc() ?

no, that's just changing the name of the sub procedure, it doesn't affect
the code itself.
or would it be easier just to
attach a hyperlink to the button?

to just open a Word doc from Access, i'd think a hyperlink would work, or
the FollowHyperlink action in VBA. if you run into problems with that, you
could try modifying fredg's code. the following is untested by might work,
as

Sub OpenWordDoc()
On Error Resume Next
Dim objWord As Object

Set objWord = CreateObject("Word.Application")

objWord.Documents.Open("C:\Path to
Folder\YourDocName.doc")

Set objWord = Nothing

End Sub

if that doesn't work, try removing the last line *before* End Sub.

hth
 
as a note to the above you need to reference the word library

to do this open vba then click on tools and then references

then find in the list microsoft word X.0 object library

where x is the version of your word

as a note there should only be one

hope this helps

Regards
Kelvan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top