bradyboyy88
Well-known Member
- Joined
- Feb 25, 2015
- Messages
- 562
Hi,
I have a function that opens files and does not have much problem except it cannot seem to open excel files while my modeless userform is open. If my userform is not open then for some reason it works. So to get around this I want to use wildcards to catch any type of excel file extension (ie, x*** or x****) in an if statement and open the excel file another way.
I have a function that opens files and does not have much problem except it cannot seem to open excel files while my modeless userform is open. If my userform is not open then for some reason it works. So to get around this I want to use wildcards to catch any type of excel file extension (ie, x*** or x****) in an if statement and open the excel file another way.
Code:
Sub OpenFile(StringPath As String)
If fso.GetExtensionName(StringPath) = "xls" Or fso.GetExtensionName(StringPath) = "xlsm" Then
Dim xlApp As Application
Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Open StringPath
xlApp.Visible = True
Set xlApp = Nothing
Else
Dim Result As Long
Result = ShellExecute(0&, vbNullString, StringPath, _
vbNullString, vbNullString, vbNormalFocus)
If Result < 32 Then MsgBox "Error"
End If
End Sub
Last edited: