Reputation: 241
I'm working in VBA. Right now, I'm in UserForm3. There is a text box that displays a user-defined path.
What I need to do next is actually get the file to open. I was trying to use a shell but it isn't working. Anyone know why?
Private Sub Open_Button_Click()
Dim myPath As String
myPath = FileName.Text 'Gets the string, FileName, from module 1
Dim shell As Object
Set shell = CreateObject("Shell.Application")
shell.Open myPath
End Sub
The alternative version, and the one I'd prefer to use, is this:
Private Sub Open_Button_Click()
Dim shell As Object
Set shell = CreateObject("Shell.Application")
shell.Open FileName
End Sub
Maybe I'm just tired, but I'm not seeing why it isn't working. I've been toying with it for awhile.
I'm using Autodesk Inventor 2011...running it through VBA Editor
Thanks ahead of time, Alyssa
JPEG: https://i.sstatic.net/YkHfF.jpg
EDIT 1, What Has Been Tried So Far:
(from help in comments)
-setting it to modeless from modal (nothing happens)
-double-clicking the file to make sure it opens (it does)
-putting file in separate module and running (nothing happens)
Upvotes: 2
Views: 532
Reputation: 241
Got it!
Private Sub Open_Button_Click()
Dim myPath As String
myPath = FileName.Text 'Gets the string, FileName, from module 1
Dim Shell As Object
Set Shell = CreateObject("Shell.Application")
Shell.Open (myPath)
End Sub
I just enclosed "myPath" in the Shell.Open function.
Upvotes: 2