Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / November 2006

Tip: Looking for answers? Try searching our database.

Macro that creates desktop shortcut

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
A1pro - 22 Nov 2006 16:47 GMT
Hello,

I'm trying to write a macro that creates a shortcut on desktop for internet
explorer so that it opens a particular website, let's say my isp 62.30.31.74

two questions:

1st is it possible to do this?
2nd is it possible to embed it  on a email so that several people have the
shortcuts created

TIA
A1pro - 22 Nov 2006 16:53 GMT
I found this
Sub shortcut()

On Error Resume Next
   'Dim wsShell As New WshShell
   'Dim wsSCut As WshShortcut
   Dim strCommandLine As String 'Command Line for shortcut to run
   strCommandLine = Chr(34) & "C:\Program Files\Internet
Explorer\IEXPLORE.EXE" & "62.30.31.74" & Chr(34) '62.30.31.74
   'strCommandLine = strCommandLine & " /WrkGrp " & Chr(34) &
"C:\Security.mdw" & Chr(34)
   'strCommandLine = strCommandLine & " " & Chr(34) & "C:\MyDb.mdb" & Chr(34)
   Set wsSCut = wsShell.CreateShortcut("D:\Documents and
Settings\jzywr0\Desktop\ShortcutTomyexplorer.lnk")
   With wsSCut
       .TargetPath = strCommandLine
       .Save
   End With
   
   Set wsSCut = Nothing
   Set wsShell = Nothing
End Sub

but does not work
if I uncomment  wsshell it complains

I guess I need to add a reference though no idea which reference

any ideas?

if i uncomment

> Hello,
>
[quoted text clipped - 8 lines]
>
> TIA
Michael Bauer [MVP - Outlook] - 23 Nov 2006 06:56 GMT
You can call the object without a ref:
   Dim WSH As Object

   Set WSH = CreateObject("WScript.Shell")

For  a ref select 'Windows Script Host Object Model'. In the Object Browser
it's then called 'IWshRuntimeLibrary'.

Signature

Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
 -- www.VBOffice.net --

Am Wed, 22 Nov 2006 08:53:02 -0800 schrieb A1pro:

> I found this
> Sub shortcut()
[quoted text clipped - 40 lines]
>>
>> TIA
A1pro - 23 Nov 2006 09:50 GMT
Thanks that works great

One thing i'm struggling with now is that, .targetpath seems to add quotes
(") at the beginning and end of whatever you set .targetpath to be.

Is there anyway around this. Because that way you cannot set a shortcut to a
webpage.

command needed to link to a webpage: "C:\Program Files\Internet
Explorer\IEXPLORE.EXE" 62.30.31.74

if I set .targetpath to be : "C:\Program Files\Internet
Explorer\IEXPLORE.EXE" 62.30.31.74

The result is "C:\Program Files\Internet Explorer\IEXPLORE.EXE 62.30.31.74"
which does not work.

Any ideas?

Also is there an easy way to embed this macro on an email.

So when the recipient opens the email, it will run the macro automatically

TIA

> You can call the object without a ref:
>     Dim WSH As Object
[quoted text clipped - 52 lines]
> >>
> >> TIA
A1pro - 23 Nov 2006 10:38 GMT
Ok, So I found out that if you just set targetpath to http://ipaddress it works

Now I need to create it on desktop. This has to go to several people, and I
do not know their desktop filepaths

I found this command
DesktopPath = WSHShell.SpecialFolders("Desktop"), it works fine for
scripting but I can't make it work on vba

any ideas?

TIA

> Thanks that works great
>
[quoted text clipped - 77 lines]
> > >>
> > >> TIA
A1pro - 23 Nov 2006 10:57 GMT
This seems to do the programatic trick:
Sub CreateShortcut()

On Error Resume Next
   
   Dim wsShell As Object
   Dim wsSCut As Object
     
   Set wsShell = CreateObject("WScript.Shell")
 
   DesktopPath = wsShell.SpecialFolders("Desktop") 'Finds Desktop folder
   
   shortcutPath = DesktopPath & "\" & "telewest.lnk" ' adds shortcut name
   
   Set wsSCut = wsShell.CreateShortcut(shortcutPath) ' creates shortcut
   
   
   With wsSCut
       .TargetPath = "http://62.30.31.74" ' this selects iexplorer and sets
the ip address
       .Save
   End With
   
   Set wsSCut = Nothing
   Set wsShell = Nothing
End Sub

Now I'm trying to think how to distribute it.

Any way to embed this on an email?
or do security issues get on the way?

any help would be appreciated

TIA
Michael Bauer [MVP - Outlook] - 24 Nov 2006 06:27 GMT
Hopefully there's no way to get it executed automatically. Maybe you can
create a *.vbs file, attach that to the e-mail and ask the user to save the
attachment as a file and run it.

Signature

Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
 -- www.VBOffice.net --

Am Thu, 23 Nov 2006 02:57:01 -0800 schrieb A1pro:

> This seems to do the programatic trick:
> Sub CreateShortcut()
[quoted text clipped - 31 lines]
>
> TIA
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.