Open a file in windows association

johanhjalmarsso

Registered User.
Local time
Today, 06:02
Joined
Jul 12, 2005
Messages
26
I want to open a image file external outside access. I want to have a VBA line that opens a specified image with the default association of windows.

Example:
.jpg is opened with the same program as when doubleclicking in explorer
and i want to do this in access. open a image with the associated program in windows
 
johanhjalmarsso said:
I want to open a image file external outside access. I want to have a VBA line that opens a specified image with the default association of windows.

Example:
.jpg is opened with the same program as when doubleclicking in explorer
and i want to do this in access. open a image with the associated program in windows

This is the solution:
http://www.access-programmers.co.uk/forums/showthread.php?t=88923
 
Searching this forum is such a novel idea. :p

Pay attention to the ShellExecute method I am using to open a file in my
Browse [Find a directory or file] sample.
 
Hi,

I have a similar problem, in that certain file types of file will not open with the wonderful examples given freely in this forum so far.

Ghudson's FindFileandFolders() example which uses the ShellExecute command is most promising but doesn't yield the result.

The application.followhyperlink is less good, if it doesn't know the file type, it throws an error and goes to the vba code with a message saying "cannot open this file" and with the debug and end buttons.

What do I have? well, quite bespoke file types such as .nbp and .cmg which are associated with acoustics programs.

.nbp files should open with C:\Program Files\Norsonic\NorBuild\Norbuild.exe

.cmg files should open with C:\Program Files\01dB\01dB Software\dBBati32.exe

This is my bit of code doing the file opening:
Code:
Private Sub lstboxProjectFiles_DblClick(Cancel As Integer)
    'Application.FollowHyperlink Me.ProjectPath & "\" & Me.lstboxProjectFiles
    nDT = GetDesktopWindow()
    nApp = ShellExecute(nDT, "Open", Me.ProjectPath & "\" & Me.lstboxProjectFiles, "", "C:\", SW_SHOWNORMAL)
    DoEvents

End Sub
So, my question...
How do I MANUALLY set file associations within access' vba code?
so that:

If filename = *.nbp Then
open with norbuild.exe
End If

If filename = *.cmg Then
open with dBBati32.exe
End If

etc

N.B. I'd probably use a CASE statement rather than an if then else.


I look forward to your response(s) i shall in the meantime, keep searching and trying.
 

Users who are viewing this thread

Back
Top Bottom