Using Shell to open UDL files (1 Viewer)

neoartz237

Tensai
Local time
Today, 07:52
Joined
Feb 12, 2007
Messages
65
I want to open my udl files programmatically so users can do the changing in just one sandbox. But, the Shell() function seems to only supprt exe files. Is there other ways to do this? PLease help
 

MarkK

bit cruncher
Local time
Today, 07:52
Joined
Mar 17, 2004
Messages
8,186
See if this works. Requires references to "Microsoft Scripting Runtime", and "Microsoft Shell Controls and Automation"
Code:
Private Sub RunFile(filespec As String)
'  Opens a file in the program for which that file's extension 
'     is registered with Windows.
'  Fails if "filespec" does not exists.
'  Fails if the file type does not have an "Open" verb.
   Dim fso As New Scripting.FileSystemObject
   Dim sApp As New Shell32.Shell
   Dim sFolder As Shell32.Folder
   Dim sFile As Shell32.FolderItem
   
   ' Namespace() method of sApp, given folder name, returns a folder object.
   Set sFolder = sApp.NameSpace(fso.GetParentFolderName(filespec))
   ' ParseName() method of the folder, given a filename, 
   ' returns a FolderItem object.
   Set sFile = sFolder.ParseName(fso.GetFileName(filespec))
   ' Open is commonly available, but this fails if not.
   sFile.InvokeVerb "Open"
End Sub
Cheers,
Mark
 

neoartz237

Tensai
Local time
Today, 07:52
Joined
Feb 12, 2007
Messages
65
Worked, Thanks!
 

Users who are viewing this thread

Top Bottom