![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
Ads |
#2
|
|||
|
|||
![]()
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 "A1pro" wrote: 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 |
#3
|
|||
|
|||
![]() 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'. -- 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() 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 "A1pro" wrote: 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 |
#4
|
|||
|
|||
![]()
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 "Michael Bauer [MVP - Outlook]" wrote: 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'. -- 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() 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 "A1pro" wrote: 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 |
#5
|
|||
|
|||
![]()
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 "A1pro" wrote: 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 "Michael Bauer [MVP - Outlook]" wrote: 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'. -- 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() 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 "A1pro" wrote: 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 |
#6
|
|||
|
|||
![]()
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 |
#7
|
|||
|
|||
![]() 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. -- 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() 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
New Mail Desktop Shortcut | Rob D. | Outlook - General Queries | 9 | August 21st 06 09:42 PM |
desktop shortcut for Outlook Calendar | MartinY | Outlook - Calandaring | 1 | May 12th 06 02:23 AM |
Desktop shortcut for the Address Book? | Fuzzy Logic | Outlook - General Queries | 8 | March 30th 06 12:46 AM |
Desktop Shortcut for viewing contacts | VFQuestion | Outlook - Using Contacts | 0 | January 27th 06 05:52 PM |
desktop shortcut for Outlook Calendar | Luc | Outlook - Calandaring | 0 | January 19th 06 09:49 PM |