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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

dk

MrExcel MVP
Joined
Feb 15, 2002
Messages
2,942
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
 

Paul_R

New Member
Joined
Sep 24, 2002
Messages
5
Is there a command that doesn't open a new instance of Word every time?
 

dk

MrExcel MVP
Joined
Feb 15, 2002
Messages
2,942
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
 

Paul_R

New Member
Joined
Sep 24, 2002
Messages
5
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.
 

Forum statistics

Threads
1,181,105
Messages
5,928,098
Members
436,588
Latest member
mummabare

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
Top