Form Buttons

jamienwood

Board Regular
Joined
Apr 14, 2002
Messages
133
What code can i use to make a file open when i clikc a button on a form, it is actuially going to be a help file written in Microsoft word called RepotPrinterHelp.doc
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hello,

Something like this.

Dim wdApp As Object, wdDoc As Object

Set wdApp = CreateObject("WORD.APPLICATION")
wdApp.Documents.Open "C:Folder NameRepotPrinterHelp.doc"
wdApp.Visible = True
 
Upvote 0
This code uses GetObject to see if an instance of Word exists. If it does, then it uses that. If not, it will create a new one.

Code:
Sub Test()
Dim wdApp As Object, wdDoc As Object

On Error Resume Next
Err.Clear
Set wdApp = GetObject(, "WORD.APPLICATION")
If Err.Number <> 0 Then
Set wdApp = CreateObject("WORD.APPLICATION")
End If

On Error GoTo 0
wdApp.Documents.Open "C:temptest file.rtf"
wdApp.Visible = True
AppActivate "Microsoft Word"
End Sub
 
Upvote 0
That looks good will give it a try,

thanks.

Iv'e used a similar method to catch trying to open an excel sheet twice but didn't twig the connection.
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,038
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top