VBA Target Path (1 Viewer)

Neilster

Registered User.
Local time
Today, 05:45
Hi Guys

I'm trying to set the desktop icon using VBA which is fine, however the shotcut isn't picking up the target path.

Any ideas?

With CreateObject("WScript.Shell")
With .CreateShortCut(.SpecialFolders("Desktop") & "\Demo Database.lnk")
.TargetPath = Environ("userprofile") & "\Documents\Demo Database\DemoDatabase.accdb"
.WindowStyle = 1
.Hotkey = ""
.IconLocation = Environ("userprofile") & "\Documents\Demo Database\cloud.ico, 0"
.Description = "Test Icon Substitution"
.WorkingDirectory = Environ("userprofile") & "\Documents\Demo Database\DemoDatabase.accdb"
.Save
End With
End With
 

Neilster

Registered User.
Local time
Today, 05:45
Hi Minty

Thanks for getting back to me, I've sorted it and the code works fine, just me being silly. However I am trying to get it from a Network drive and can't get it to work???

:banghead::banghead::banghead:
 

GinaWhipp

AWF VIP
Local time
Today, 08:45
Hmm, get it from a Network Path? You mean copy the Shortcut from the Network or have the Shortcut link from the Network?

Note, when using the Network use the UNC Path not a drive letter.
 

Minty

AWF VIP
Local time
Today, 13:45
A network path won't have a Environ("userprofile") - that is a local machine environment string.

As Gina said a network path would be something like \\Server\SharedFolderName\yourfile.pdf
 

Minty

AWF VIP
Local time
Today, 13:45
No, by definition a network share would be completely specific to the network you are connected to.

We store dedicated storage paths in a system table, and look them up at database startup. This means if we ever move a centralised store we only need to change the value in the table once - not recode the whole thing.

So the value today for the field InvStoragePath might be \\Datastore\Invoices but if we had to, we could change it to \\NewData\Invoices by simply updating the field value.
 

Users who are viewing this thread

Top Bottom