LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Can I run a file with a known extension from Excel VBA

Try something like this -

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

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Sub test()
Dim ret As Long
Dim sFile As String

sFile = "C:\Temp\test.txt"

ret = ShellExecute(GetDesktopWindow, vbNullString, sFile, _
vbNullString, vbNullString, vbNormalFocus)

If ret 32 Then
' it worked
Else
' it failed, the code 1-32 will give the reason, eg
' 2 file not found
' 31 file not associated
Debug.Print ret
End If

End Sub

If it doesn't work and you are sure the extention is correctly associated
and sure the file is correct, try changing the first vbNullString to "open"
(with the quotes)

Regards,
Peter T


"MikeZz" wrote in message
...
Hi,
I have a file with a ".mac" extention that's associated with an
application
in windows.

Is there a way that I can have Excel run the file from within VBA?

Thanks
MikeZz



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine Excel file version with no file extension. tjlumpkin Excel Discussion (Misc queries) 2 July 23rd 09 06:59 AM
Retrieving Excel File extension based on XL File Format Enumeratio Sasikumar Kannappan Excel Programming 2 June 24th 09 03:59 PM
excel file extension Mr Lost Excel Discussion (Misc queries) 1 April 26th 07 09:01 AM
import snp file extension to MS Excel TSS Excel Discussion (Misc queries) 2 September 20th 05 11:28 PM
Excel File Extension Randy[_13_] Excel Programming 5 December 4th 03 01:51 AM


All times are GMT +1. The time now is 06:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"