Commnd Button Wizard

macamarr

Board Regular
Joined
Nov 1, 2002
Messages
52
Hello,
I import an excel file and when I insert a command button I can set up to open my choice of applications. So I was wondering if it is possible when I open excel with the command button to have it point to the excel file I want to open or have it open the target file? Thanks!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I haven't done it often but you can do it a few different ways.

1. You can go into the properties of the button and under "Hyperlink Address search for your file.

2. Create a Macro using the "RunApp" Action using the following syntax:

"C:\Program Files\Microsoft Office\Office\Excel.exe" "C:\Documents and Settings\My Documents\YourExcelFile.xls"

The 1st set of quotations should be standard but the second set depends on the path to your file.

Once the Macro is created you can either go into the wizard and select "Run Macro" and choose the Macro, or in the On click event property you can choose the macro.

3. Use visual basic:

This example is the same as # 2 but converted to VB, There are other ways with VB I just can't find my notes on this subject right now.


Function Autoopen()
On Error GoTo Autoopen_Err

Call Shell("""C:\Program Files\Microsoft Office\Office\Excel.exe"" ""C:\Documents and Settings\My Documents\YourFile.xls""", 1)


Autoopen_Exit:
Exit Function

Autoopen_Err:
MsgBox Error$
Resume Autoopen_Exit

End Function



Ziggy
 
Upvote 0

Forum statistics

Threads
1,221,543
Messages
6,160,422
Members
451,644
Latest member
hglymph

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