undefined variable: msoFileDialogFilePicker

  • Thread starter Thread starter froggie
  • Start date Start date
F

froggie

Guest
help!!!
would you plz help me?
I wrote an access application,it did work on my computer, but when I copy it to other 4 computers and run it, system tell me : "compile error: undefined variable:msoFileDialogFilePicker". My computer and the 4 computers have the same hardware and software environment, they have the same operation system and same ms office version. The ms access on All of the 5 computer have been installed the same quote or object library:

visual basic for applications
ms access 9.0 object library
ms office 9.0 object library
ole automation
ms DAO 3.6 object library

what should I do? would you plz help me? my code is as follows:

------------------------------
Sub getFileName()
' display an office OpenFile dialog
' get a filename after user select a file from the office OpenFile dialog
' and put this picture file into an image object.

Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "select a picture"
.Filters.Add "all files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "bitmap", "*.bmp"
.FilterIndex = 1
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![PicPath].Visible = True
Me![PicPath].SetFocus
Me![PicPath].Text = fileName
Me![PersonID].SetFocus
Me![PicPath].Visible = False
ErrorMessege.Visible = False
End If
End With
End Sub
 
You need to ensure that their computers have the same references checked as your PC has. From within an open module, click Tools / References... and notice which references are checked on your PC. Now go to the other four PCs and ensure they have the same references checked.

I would suggest using an API instead of a referenced control. Search this site for "browsing" and you will find some good examples. Also search for user "ghudson" for I have posted links to some code from other sites.

HTH
 
thank you for your help,
but I can't find what is the difference between the reference of my pc and other 4 pcs , and I can't how to use api, I can't find "browsing" on the site, there is no key search on this site, is it?
any way, thank you very much!, have a good weekend!
 
Search results for "browsing" -
 
Mile-O-Phile, How did you add that search button with the link attached to your post? Or is that something that only you can do as a "Moderator"?

froggie, You need to learn how to use this sites "Search" function. The button is always in the top-right corner of each page within this site. Searching [before posting] for answers to your questions will save everybody involved a lot of time.

Check out these links to some common APIs for calling the standard windows "File Open" and "Browse Folder" using VBA...

API: Call the standard Windows File Open/Save dialog box
http://www.mvps.org/access/api/api0001.htm

API: BrowseFolder Dialog
http://www.mvps.org/access/api/api0002.htm
 
Last edited:
ghudson said:
Mile-O-Phile, How did you add that search button with the link attached to your post?

Nested vb Code:

[URL=http:www.mywebsite.x][IMG]http://www.interweb.com/mypicture.jpg[/IMG][/URL]
 
HI,

I have got this to work for the most part using your referenced "API: Call the standard Windows File Open/Save dialog box"

My intent is to call the following Code with a button in access 2007 and be able to open a bitmap file from one location and save it in another. It goes through the process ok but am missing the actual method where the actual copy is happening. I am lost at this part as to what command I should to do this ...

I also created the module per the referenced method above also.

the code is as follows:

Dim strFilter As String
Dim strInputFileName as string
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
Note that in order to call the Save As dialog box, you can use the same wrapper function by just setting the OpenFile option as False. For example,

'Ask for SaveFileName
strFilter = ahtAddFilterItem(myStrFilter, "Excel Files (*.xls)", "*.xls")
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)
 

Users who are viewing this thread

Back
Top Bottom