create shortcut with Mkdir

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
 
G

Graham Mandeno

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
 
M

Maldo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top