|
-
November 24th, 1999, 02:18 PM
#1
File association
How to get file assocaition in VB ?I have a file open dialog box.If I select a doc file it should open it with latest MSword,if it is pdf it should open in Acrobat reader etc.I can't use word objects or shell command bcoz i will have to hard code the progID which is diff. for diff. versions of word. like Word.Application.8, Word.Document.6 etc.
Any suggestions ???
Thanx in advance.
-
November 24th, 1999, 02:52 PM
#2
Re: File association
See http://www.freevbcode.com/ShowCode.Asp?ID=12. Though the example is title Open a web page in the default browser, it will actually open any file in the program with which it is associated.
-
November 24th, 1999, 03:04 PM
#3
Re: File association
You can however, use the ShellExecute API method. This runs the default program that the file is associated with.
Paste the following declaration into your VB project:
private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(byval hwnd as Long, byval lpOperation as string, byval lpFile as string, _
byval lpParameters as string, byval lpDirectory as string, byval nShowCmd _
as Long) as Long
Then, to run the file use the following code:
ShellExecute(me.hWnd, "Open", FileName, "", "", 1)
replacing FileName with the name and path of the file.
psiclone
-
November 24th, 1999, 04:07 PM
#4
-
November 24th, 1999, 04:08 PM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|