By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,422 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,422 IT Pros & Developers. It's quick & easy.

Problem with generating file shortcut in VB

P: n/a
I'm trying to generate a shortcut file from VB. The code below is a cutdown
version of some code I found on the net that is supposed to do the job

The compiler complains about "WshShell" in the 5th line below. It says
"Reference to a non-shared member requires an object reference". I'm not
sure what it's trying to tell me here.

thanks for any help

I'm using Visual Studio 2003. To get the IWshRuntimeLibrary, from the menu
bar: project/add references/com/Windows Script Host Object Model

Imports IWshRuntimeLibrary

Module Module3

Sub zzz()

Dim shortCut As IWshRuntimeLibrary.IWshShortcut

shortCut = CType(WshShell.CreateShortcut("C:\AAQQ.lnk"), _

IWshRuntimeLibrary.IWshShortcut)

End Sub
Apr 22 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello Mike,

shortCut = CType((New IWshRuntimeLibrary.WshShell).CreateShortcut("C:\AA QQ.lnk"), IWshRuntimeLibrary.IWshShortcut)

Regards.

"Mike" <mi******@hotmail.com> escribió en el mensaje news:12*************@corp.supernews.com...
| I'm trying to generate a shortcut file from VB. The code below is a cutdown
| version of some code I found on the net that is supposed to do the job
|
| The compiler complains about "WshShell" in the 5th line below. It says
| "Reference to a non-shared member requires an object reference". I'm not
| sure what it's trying to tell me here.
|
| thanks for any help
|
| I'm using Visual Studio 2003. To get the IWshRuntimeLibrary, from the menu
| bar: project/add references/com/Windows Script Host Object Model
|
|
|
| Imports IWshRuntimeLibrary
|
| Module Module3
|
| Sub zzz()
|
| Dim shortCut As IWshRuntimeLibrary.IWshShortcut
|
| shortCut = CType(WshShell.CreateShortcut("C:\AAQQ.lnk"), _
|
| IWshRuntimeLibrary.IWshShortcut)
|
| End Sub

Apr 23 '06 #2

P: n/a
Thanks Jose, that did the trick.

Mike

"José Manuel Agüero" <chema012 en hotmail.com> wrote in message
news:ek**************@TK2MSFTNGP03.phx.gbl...
Hello Mike,

shortCut = CType((New
IWshRuntimeLibrary.WshShell).CreateShortcut("C:\AA QQ.lnk"),
IWshRuntimeLibrary.IWshShortcut)

Regards.

"Mike" <mi******@hotmail.com> escribió en el mensaje
news:12*************@corp.supernews.com...
| I'm trying to generate a shortcut file from VB. The code below is a
cutdown
| version of some code I found on the net that is supposed to do the job
|
| The compiler complains about "WshShell" in the 5th line below. It says
| "Reference to a non-shared member requires an object reference". I'm not
| sure what it's trying to tell me here.
|
| thanks for any help
|
| I'm using Visual Studio 2003. To get the IWshRuntimeLibrary, from the menu
| bar: project/add references/com/Windows Script Host Object Model
|
|
|
| Imports IWshRuntimeLibrary
|
| Module Module3
|
| Sub zzz()
|
| Dim shortCut As IWshRuntimeLibrary.IWshShortcut
|
| shortCut = CType(WshShell.CreateShortcut("C:\AAQQ.lnk"), _
|
| IWshRuntimeLibrary.IWshShortcut)
|
| End Sub
Apr 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.