ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running a macro from a desktop icon shortcut (https://www.excelbanter.com/excel-programming/271601-running-macro-desktop-icon-shortcut.html)

Sofia

Running a macro from a desktop icon shortcut
 
Hello.

I have a macro written in my workbook. I want to run it
by clicking on an icon on my desktop without having to
open MS Excel. I know this can be done in MS Access.

Also, I used the Shell function to run an .exe with a '0'
argument so it will be hidden. Do I have to end it or
close it or will it do that by itself when the .exe
finishes running?

-Sofia

Chip Pearson

Running a macro from a desktop icon shortcut
 
Sofia,

Try writing a VB Script file containing the following:

Dim XL
Dim WB
Set XL = CreateObject("Excel.Application")
Set WB = XL.Workbooks.Open("C:\Book1.xls")
XL.Run "TestMacro"
WB.Close
XL.Quit
Set WB = Nothing
Set XL = Nothing

Put this script file on you desktop.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Sofia" wrote in message
...
Hello.

I have a macro written in my workbook. I want to run it
by clicking on an icon on my desktop without having to
open MS Excel. I know this can be done in MS Access.

Also, I used the Shell function to run an .exe with a '0'
argument so it will be hidden. Do I have to end it or
close it or will it do that by itself when the .exe
finishes running?

-Sofia




Sofia K

Running a macro from a desktop icon shortcut
 


I tried your VB script and works wonderfully except for one detail.

Every time I run the script, after it is done, it pops up a 'File
Available for Use' window telling me that my excel file is available for
editing giving me the option to open it as 'read/write' or 'cancel'.
It's doing this everytime. Is there a way to shut this off? Other than
this, I've run the script multiple times and works just fine.

-Sofia

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 11:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com