• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Unable to make use of GetOpenFilename() method

shahin

Active Member
I've created a script in vba to open an excel file using Application.GetOpenFilename(). When I execute the script, it does lead me to that exact location but can't open that file. I'm only after the method I'm on to. How can I make it successful?

Address to the .xlsx file "C:\Users\WCS\Desktop\files\coworking\demo.xlsx"

This is I've written so far:
Code:
Sub OpenFile()
    Dim fileName$
   
    ChDir "C:\Users\WCS\Desktop\files\coworking"

    fileName = Application.GetOpenFilename("demo(*.xlsx),*.xlsx")
    If fileName <> "False" Then
        Workbooks.Open fileName
    End If
End Sub
 
shahin
1) Have You checked what is fileName's value?
2) Have You tested to write 'only' demo.xlsx after Workbooks.Open?
3) if 2nd step won't work then You should add path in front of fileName
 
Back
Top