create shortcut with Mkdir

  • Thread starter Thread starter shiro
  • Start date Start date
S

shiro

Hi all,
I can create a folder automatically from Access VBA
with MkDir statement.But how to create a shortcut
to fhe folder created using MkDir.I want to put the
shorcut on my dekstop or user dekstop.

Thank's

Rgds,

Shiro
 
Hi Shiro

The following code should work for you:

Dim oShell As Object
Dim oShortcut As Object
Dim sDesktop As String
Set oShell = CreateObject("WScript.Shell")
With oShell
sDesktop = .SpecialFolders("Desktop")
Set oShortcut = .CreateShortcut(sDesktop & "\" & "Shortcut to MyFolder"
& ".lnk")
End With
With oShortcut
.TargetPath = "c:\MyFolder"
.Save
End With
Set oShortcut = Nothing
Set oShell = Nothing
 
I was about to post this same type of request. I was hoping there was a way
to do this via VBA. I used this code in my application and it worked
perfectly! Thanks a million! MVPs are the best!!!

Maldo

Graham Mandeno said:
Hi Shiro

The following code should work for you:

Dim oShell As Object
Dim oShortcut As Object
Dim sDesktop As String
Set oShell = CreateObject("WScript.Shell")
With oShell
sDesktop = .SpecialFolders("Desktop")
Set oShortcut = .CreateShortcut(sDesktop & "\" & "Shortcut to MyFolder"
& ".lnk")
End With
With oShortcut
.TargetPath = "c:\MyFolder"
.Save
End With
Set oShortcut = Nothing
Set oShell = Nothing


--
Good Luck :-)

Graham Mandeno [Access MVP]
Auckland, New Zealand

shiro said:
Hi all,
I can create a folder automatically from Access VBA
with MkDir statement.But how to create a shortcut
to fhe folder created using MkDir.I want to put the
shorcut on my dekstop or user dekstop.

Thank's

Rgds,

Shiro
 
Back
Top