GetOpenFilename

L

Leo

Hi -

I am trying to use the method 'GetOpenFilename'.

I am pretty sure my code is correct cause I copied it
from another application. However, I get this compile
error: "Method or data member not found"

Would you be able to tell me which library reference this
falls under. I am pretty sure that I have it checked.

Any ideas as to why I am seeing this error?

Thanks much!!
 
L

Leo

Hi Nick -

Here it is. Thanks!!

_______________________________________________________

Private Sub cmd_Import_Data_Click()

On Error GoTo Err_cmd_Import_Data_Click

Dim x As Integer
Dim filetoOpen As String
Dim XLapp As Object
Dim XLFile As String
Dim XLSheet As String

'Find Standardized file

MsgBox "Please specify the location of the
Standardized File", vbOKOnly, "Locate File"
filetoOpen = Application.GetOpenFilename("Excel Files
(*.xls), *.xls", , _
"Please select the StandardizeFile.xls file to link
to")
If filetoOpen <> "" Then
FileName = Right(filetoOpen, Len(filetoOpen) -
InStrRev(filetoOpen, "\"))
On Error Resume Next
If IsError(Windows(FileName).Activate) Then
Workbooks.Open filetoOpen
Else
Windows(FileName).Activate
End If

Set XLapp = GetObject(, "Excel.Application")

XLapp.Visible = True
XLFile = FileName

For z = "tbl_A" To z = "tbl_B"

XLSheet = XLapp.ActiveWorkbook.Sheets(z).Name

DoCmd.TransferSpreadsheet , acImport,
acSpreadsheetTypeExcel8, XLapp.ActiveWorkbook.Sheets
(z).Name, XLFile, True, XLSheet

Next z

End Sub

Exit_cmd_Import_Data_Click:
Exit Sub

Err_cmd_Import_Data_Click:
MsgBox Err.Description
Resume Exit_cmd_Import_Data_Click

End Sub
 
N

Nick Coe \(UK\)

Can't help you with this one. I thought
Application.GetOption was an Excel property. It's not a
property of the Access2000 Application object which is all
my head is refreshed with at the moment.

If I want a user to select a file(s) from a directory I use
the code, or a variant of, from the Access Developers
Handbook or from the Access Web:-

http://www.mvps.org/access/api/api0001.htm
 
B

Brendan Reynolds

Nick is correct, the Access Application object does not have a
GetOpenFilename method. I also use a variation of the API code at the URL
that Nick posted.

I believe that recent versions of Office added a method to the Office object
library, but I can't comment on that. I have never used it, because I need a
method that will work with a runtime installation, where I cannot depend on
any specific version of Office being present.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Top