-
It seems that, in effect, there isn¡¯t much difference between the Shell and ShellExecute functions. I have tried both of them and still the problem I proposed in my ¡°call an outside application¡± topic remains. HeSaidJoe has suggested a resolution, but I am stupid enough not to be able to solve it, for I must open a document file in that directory (with a space in it).
-
<?>
application¡± topic 'what is it with your fonts....
that stuff is hard to read when it keeps popping in
and out.
Post your code so I can get a better idea of how to deal with the situtation.
-
Dosen't somthing like this work ????
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
ShellExecute hwnd, "Open", "C:\my documents\my stuff.doc", "", "c:\my documents", 9
-
<?>
This works with spaces in the folder name and
with spaces in the file name.
Code:
'put this in a bas module
'
Public Declare Function ShellEx Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As Any, _
ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
'
'Form events
'open a file with it's associated application
Private Sub Command1_Click()
'
Dim sFileName As String, x As Long
sFileName = "c:\my documents\my special file.txt"
x = ShellEx(Me.hwnd, "open", sFileName, "", "", 1)
'=====================================
End Sub
-
I have succeeded. Thank you, HeSaidJoe and joefoulkes.
-
And then there were still problems, which came up with document files having an association different from the default one. For example, on one of my computers ACDSee is installed which is associated with the .BMP files whose default server should have been MSPaint.exe or Pbrush.exe. When I used the ShellExecute function to open a .BMP file, it called up ACDSee with which I could not edit the file. I finally solved the problem with the following code:
strWinDir = ¡°C:\Windows¡±
strBmpFile = ¡°C:\Program Files\Microsoft Exchange\Image.bmp¡±
Shell strWinDir & ¡°\Pbrush.exe ¡° & Chr$(34) & strBmpFile & Chr$(34), vbMaximizedFocus
Thank you all the same, HeSaidJoe and joefoulkes.
-- IHailJoe