Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / October 2005

Tip: Looking for answers? Try searching our database.

How do I make a button to open a specific Word doc?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jmuirman - 31 Oct 2005 14:53 GMT
How do I make a button to open a specific Word doc? I want to hit a button on
my form to open a a specific word document...

Thanks,

John
Ofer - 31 Oct 2005 15:01 GMT
To open a word document, create reference to Microsoft Word and then

Function Open_WordDoc()

Dim objWord As Word.Application
Dim objDoc  As Word.Document
Dim DocPath As String

DocPath = "Path and name of the document"

Set objWord = New Word.Application
Set objDoc = objWord.Documents.Open(DocPath)

objDoc.Activate  
objDoc.PrintOut   ' To print out
objWord.Visible = True  ' To display

End Function
===========================
Or use the FollowHyperLink

Dim DocLocationAndName as String
DocLocationAndName = "C:\FileName.Doc"
application.FollowHyperlink DocLocationAndName
Signature

If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck

> How do I make a button to open a specific Word doc? I want to hit a button on
> my form to open a a specific word document...
>
> Thanks,
>
> John
Van T. Dinh - 31 Oct 2005 15:31 GMT
You can simply use the FollowHyperlink method like:

   Application.FollowHyperlink "FullPathNameOfYourDoc"

Signature

HTH
Van T. Dinh
MVP (Access)

> How do I make a button to open a specific Word doc? I want to hit a button
> on
[quoted text clipped - 3 lines]
>
> John
jmuirman - 31 Oct 2005 15:46 GMT
With either method above, where do I start - do I paste code somewhere or is
there a wizard of some kind?

Thanks,

John

> You can simply use the FollowHyperlink method like:
>
[quoted text clipped - 7 lines]
> >
> > John
Ofer - 31 Oct 2005 15:57 GMT
Yes you can paste this code to the OnClick event of the button, just change
the name of the Doc File.
If you get any error, post the code you are using and specify how do you get
the name of the Document
Signature

If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck

> With either method above, where do I start - do I paste code somewhere or is
> there a wizard of some kind?
[quoted text clipped - 14 lines]
> > >
> > > John
jmuirman - 31 Oct 2005 16:38 GMT
I got several messages - I probably pasted in the wrong spot - here's the code:

End Sub
Private Sub Command76_Click()
On Error GoTo Err_Command76_Click

   Dim stDocName As String
   Dim stLinkCriteria As String

   stDocName = "FNewCases-BY CLAIMANT"
   DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command76_Click:
   Exit Sub

Err_Command76_Click:
   MsgBox Err.Description
   Resume Exit_Command76_Click
   
End Sub
Private Sub Command77_Click()
Function Open_WordDoc(C:\Documents and Settings\John Muir\My
Documents\LETTER-TEMPLATE ALL PARTIES TO LOSS.doc)

Dim objWord As Word.Application
Dim objDoc  As Word.Document
Dim DocPath As String

DocPath = "Path and name of the document"

Set objWord = New Word.Application
Set objDoc = objWord.Documents.Open(DocPath)

objDoc.Activate
objDoc.PrintOut   ' To print out
objWord.Visible = True  ' To display
   
End Function

Thanks,

John
Ofer - 31 Oct 2005 16:52 GMT
Have you created a reference to Microsoft word?
Open code (any where) select Tools > reference > add from the list Microsoft
word

About the code, try this

Private Sub Command77_Click()
Dim objWord As Word.Application
Dim objDoc  As Word.Document
Dim DocPath As String

DocPath = "C:\Documents and Settings\John Muir\My Documents\LETTER-TEMPLATE
ALL PARTIES TO LOSS.doc"

Set objWord = New Word.Application
Set objDoc = objWord.Documents.Open(DocPath)

objDoc.Activate
objDoc.PrintOut   ' To print out
objWord.Visible = True  ' To display
   
End Sub
Signature

If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck

> I got several messages - I probably pasted in the wrong spot - here's the code:
>
[quoted text clipped - 38 lines]
>
> John
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.