Following the shortcut

J

Jaspar

How can I follow a shortcut from within VBA. I guees I
will need to use a Windows API call but I don't know which.

I want to list all documents in a folder (using Dir
function) and if one of the folders is actually a
shortcut, I will need to go to the destination of this
shortcut and list the documents here.

If I rightclick on the shortcut and choose properties, I
can see the destination, but how can I access this
information from VBA?
 
L

Lars-Eric Gisslén

Jaspar,

The code below shows what the C:\WinNT\hpinfo.lnk file links to (in this
case: C:\Program\hp deskjet 960c series\hpfiui.exe).

Include 'Microsoft Shell Controls And Automation' in the reference list for
your macro project.

Sub GetLink()
Dim oShell As Shell32.Shell
Dim oFolder As Shell32.Folder
Dim oFolderItem As Shell32.FolderItem
Dim oLink As Shell32.ShellLinkObject

Set oShell = New Shell32.Shell
Set oFolder = oShell.NameSpace("c:\WinNT")
Set oFolderItem = oFolder.ParseName("hpinfo.lnk")
Set oLink = oFolderItem.GetLink

MsgBox oLink.Path

Set oShell = Nothing
Set oFolder = Nothing
Set oFolderItem = Nothing
Set oLink = Nothing
End Sub

Regards,
Lars-Eric
 
J

Jaspar

Tack så mycket, Lars

Just what I was looking for! Do you know of any good
documentation on Windows calls - I seem to pick them up on
the way, but I don't know of any other way to find them
than to ask here.

Hilsningar
Jesper
 
L

Lars-Eric Gisslén

Jaspar,

Are you in Norway or Denmark?

There are two ways to get all documentation about WinAPI and other MS
products. Get an MSDN subscription or go to msdn.microsoft.com. On the MSDN
site you can find all information you will need but it can sometimes be
quite frustrating to find the correct information. With my dev tool (not MS)
there was a *.hlp file with all WinAPI calls documented. Blistering fast to
find WinAPI calls in the help file compared to the msdn site (or CD). But
the hlp file contains only WinAPI calls and nothing else.

There should also be some free tools on the Internet that has VB examples
for a great deal of the WinAPI calls. I don't have any URL to them but I
guess someone else here perhaps use them and knows where to find them. You
may also find them with Google.

Regards,
Lars-Eric

Tack så mycket, Lars

Just what I was looking for! Do you know of any good
documentation on Windows calls - I seem to pick them up on
the way, but I don't know of any other way to find them
than to ask here.

Hilsningar
Jesper
 
J

Jaspar

Tjena, Lars-Erik

This is Denmark calling - I guess you could tell from my
lousy swedish, that I wasn't from Sweden, eh?

Thanx for the tip, Lars-Erik - I don't have a MSDN
subscription, but I do have a Visual Studio. From this I
have the API Text Viewer, but it only lists the calls and
the declaration of the calls - no hint to what the calls
can do. I guess I'll try to track down some of the free
tools you refer to.

Greetings from DK
Jesper
-----Original Message-----
Jaspar,

Are you in Norway or Denmark?

There are two ways to get all documentation about WinAPI and other MS
products. Get an MSDN subscription or go to
msdn.microsoft.com. On the MSDN
 
L

Lars-Eric Gisslén

Jaspar,

Your Swedish was OK :)

Searched on Google and found a site that might be useful
http://www.mentalis.org/agnet/apiviewer.shtml
Might be something you can make use of.

Regards,
Lars-Eric

"Jaspar" <[email protected]> skrev i meddelandet
Tjena, Lars-Erik

This is Denmark calling - I guess you could tell from my
lousy swedish, that I wasn't from Sweden, eh?

Thanx for the tip, Lars-Erik - I don't have a MSDN
subscription, but I do have a Visual Studio. From this I
have the API Text Viewer, but it only lists the calls and
the declaration of the calls - no hint to what the calls
can do. I guess I'll try to track down some of the free
tools you refer to.

Greetings from DK
Jesper
-----Original Message-----
Jaspar,

Are you in Norway or Denmark?

There are two ways to get all documentation about WinAPI and other MS
products. Get an MSDN subscription or go to
msdn.microsoft.com. On the MSDN
 
J

Jaspar

Looks great, Lars-Erik

Thanx again!
-----Original Message-----
Jaspar,

Your Swedish was OK :)

Searched on Google and found a site that might be useful
http://www.mentalis.org/agnet/apiviewer.shtml
Might be something you can make use of.

Regards,
Lars-Eric

"Jaspar" <[email protected]> skrev i meddelandet
Tjena, Lars-Erik

This is Denmark calling - I guess you could tell from my
lousy swedish, that I wasn't from Sweden, eh?

Thanx for the tip, Lars-Erik - I don't have a MSDN
subscription, but I do have a Visual Studio. From this I
have the API Text Viewer, but it only lists the calls and
the declaration of the calls - no hint to what the calls
can do. I guess I'll try to track down some of the free
tools you refer to.

Greetings from DK
Jesper

msdn.microsoft.com. On the MSDN


.
 

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

Top