Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

GetOpenFilename not working in Word 2007 VBA

Avatar of Bryce Bassett
Bryce BassettFlag for United States of America asked on
Visual Basic ClassicMicrosoft WordVB Script
10 Comments1 Solution4947 ViewsLast Modified:

Working in VBA for Word 2007.  I want my user to click a button on a userform to browse to a file, to returns a path/filename I can use elsewhere in my macro.

I've seen lots of solutions here and elsewhere that say to use the GetOpenFilename function as I do in the code below.  But this refuses to work for me.  I keep getting "Compile Error:  Method or Data member not found" with the GetOpenFilename being highlighted in my VB window.  My project already has references to the Word Object Library, Forms Object Library, and Office Object library.

Any idea why this is not working for me?  

Private Sub OpenFileButton_Click()
   Dim FilePath As String
      FilePath = Application.GetOpenFilename("XML Files (*.xml),*.xml")
   If FilePath <> "False" Then
      File2Open = FilePath
      Unload Me
   End If

End Sub
Avatar of Chris Bottomley
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answers