Launch Shortcut through VBA

joefrench

Active Member
Joined
Oct 4, 2006
Messages
357
Is it possible to launch a program through desktop shortcut with VBA? I have the following code and it is giving me an 'Invalid procedure call or argument' error
Edit: Typing the string into the Run command works fine.
Code:
'Launch ProE
Dim objWsh As Object, _
    strDesktop As String

Set objWsh = CreateObject("WScript.Shell")
strDesktop = objWsh.SpecialFolders("Desktop") & "\Wildfire 3.0.lnk"

Set objWsh = Nothing

'Debug.Print strDesktop

Shell strDesktop, vbMaximizedFocus
 
Last edited:
I can't believe they're not! How long did it take you to develop that?
It's a work in progress... Currently I've worked on it for about 6 to 8 months, but not fulltime, about 10% of my time I guess. I've got a lot of ideas for improvement (looking into Class modules now, looks promising), and also my colleagues keep the feature-requests coming... I could keep myself busy with it fulltime, but my boss won't allow me, I've gotten him to let me 'excel' for about 30 to 50% of my time now, also a work in progress :)
He thinks I should design some stuff in Pro/E now and then as well...:biggrin:

I have so many bugs in what I've developed (mainly due to premature launch forced by upper management) that I am never surprised that there is a problem. I've been able to work most of them out after learning so much on this forum.
All software has bugs, certainly the work done by amateurs... and I surely do consider myself an amateur regarding software development. But I'm eager to learn... and I surely have learned LOTS on this forum...

It's a lot like this forum.....very friendly people that are willing to help you out. (Of course you can tell some of them are slightly frustrated by the PTC product!
Some? Aren't we all? ;)
A running joke at our workplace is that we should replace ProE with MS-Paint, it can do all the same things, but with less bugs :rofl:

So, I'm signing off for the day... almost midnight here... I'll get back to you on Monday, with hopefully some answer on the original topic of this thread, we have gone OT quite badly, haven't we, hehe?
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
It's a work in progress... Currently I've worked on it for about 6 to 8 months, but not fulltime, about 10% of my time I guess. I've got a lot of ideas for improvement (looking into Class modules now, looks promising), and also my colleagues keep the feature-requests coming...

You've done a lot of work in that amount of time! Best of luck on your enhancements!
I'm just now starting to get requests....now that they've finally seen that excel is more than a calculator/word processor.

I could keep myself busy with it fulltime, but my boss won't allow me, I've gotten him to let me 'excel' for about 30 to 50% of my time now, also a work in progress :)
He thinks I should design some stuff in Pro/E now and then as well...
I have that same problem. My supervisor is always asking me "Don't you want to design something?" I say, "I am....kinda...." ;)

All software has bugs, certainly the work done by amateurs... and I surely do consider myself an amateur regarding software development. But I'm eager to learn... and I surely have learned LOTS on this forum...

I'm eager to learn as well....it's been fun learning VBA....along with HTML, javascript, css and other languages.

Some? Aren't we all? ;)
A running joke at our workplace is that we should replace ProE with MS-Paint, it can do all the same things, but with less bugs
That is a good one! I'll have to share that with my colleagues

So, I'm signing off for the day... almost midnight here... I'll get back to you on Monday, with hopefully some answer on the original topic of this thread, we have gone OT quite badly, haven't we, hehe?
Off Topic? Maybe a bit....but that happens every now and then.
Looking forward to hearing from you Monday. Have a great Weekend!
 
Upvote 0
Hello again,

I've been checking my code and been doing some testing...
In my code I either called a batchfile directly the way you use in the first post. That works. I expect all executable files will work this way (.exe, .com, .bat)
When I open a certain .eASM file (eDrawings Assembly file), I included the application location to open the application and the filename as parameter to the application. That also works.
Directly trying to open the filename, relying on the 'double-click' functionality in Explorer seems not to work :(

So, in short, I think you need to know what the parent application is, and call that one, with the filename as a parameter. To account for spaces in pathnames, also add quotes where necessary.

Example:
Code:
Sub Test()
    Dim FileName As String
    FileName = Environ("USERPROFILE") & "\Desktop\" & "test.lnk"
    FileName = "Excel " & """" & FileName & """"
    Call Shell(FileName, vbHide)
End Sub
In this case, I put a link to an Excelfile on my desktop. Since Excel can be started as is (its location is in the system-PATH), I don't need to provide the exact location of the .exe file.

I'm thinking there must be a better way to do this, it is ridiculous that you have to know the location of the parent application to open a shortcut...
I'll try to find something else, but in the meantime, you could try the workaround I explained...

ciao,
H
 
Upvote 0
I might have found a solution:

Code:
Sub Test()
    Dim FileName As String
    FileName = Environ("USERPROFILE") & "\Desktop\" & "test.lnk"
    FileName = "cmd /c " & """" & FileName & """"
    Call Shell(FileName, vbHide)
End Sub

This works without knowing which application is needed to open the shortcut...
 
Upvote 0
Thanks H! That's awesome!!
I'm glad I didn't have to go to the programs executable file....as that wouldn't work to well with our current configuration.
 
Upvote 0
I'm glad it helped you...
I can't take (all) the credit though, I found the 'cmd /c' hint via Google :)
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,487
Members
452,917
Latest member
MrsMSalt

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