ghudson
Registered User.
- Local time
- Today, 16:22
- Joined
- Jun 8, 2002
- Messages
- 6,195
Any Access / Excel automation gurus out there?
From Access 2003, I am trying to search an Excel worksheet and find and select the cell that has the text string "F Total".
I cannot set a reference to Excel because some are not using the same version of Office. I cannot have anything done to the file before hand [like a named range for the cell since that would be to easy] for I have to take and use it as is.
Below is what I am working with and usually does the job for Excel automation from Access but this time I cannot get a Find command to work from Access as it gives me the "variable not defined" error on the arguments in the Find command. When I remove everything but the .Application.Find(What:="F Total") I get the "448 - Named argument not found" error.
Is there a simple way to do what I want using simular code with Access 2003?
Thanks in advance for your help!
From Access 2003, I am trying to search an Excel worksheet and find and select the cell that has the text string "F Total".
I cannot set a reference to Excel because some are not using the same version of Office. I cannot have anything done to the file before hand [like a named range for the cell since that would be to easy] for I have to take and use it as is.
Below is what I am working with and usually does the job for Excel automation from Access but this time I cannot get a Find command to work from Access as it gives me the "variable not defined" error on the arguments in the Find command. When I remove everything but the .Application.Find(What:="F Total") I get the "448 - Named argument not found" error.
Is there a simple way to do what I want using simular code with Access 2003?
Code:
Public Sub Create60DetailsWorksheet(sPathFile As String)
On Error GoTo Err_Create60DetailsWorksheet
Dim xlApp As Object
Dim xlSheet As Object
Set xlApp = CreateObject("Excel.Application")
Set xlSheet = xlApp.Workbooks.Open(sPathFile).Sheets(1)
With xlApp
.Application.Sheets("Summary").select
.Application.Range("A1").select
[COLOR="Green"]'Access does not like this line[/COLOR]
'.Application.Find(What:="F Total", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
.Application.Find(What:="F Total").select [COLOR="Red"]'errors here but this is what I need, a simple Find command[/COLOR]
.Application.ActiveCell.Offset(0, 2).select
.Application.Selection.ShowDetail = True
.Application.Range("AF1").select
.Application.Sheets("Sheet1").Name = "60"
.Application.ActiveWorkbook.Save
.Application.ActiveWorkbook.Close
.Quit
End With
Set xlApp = Nothing
Set xlSheet = Nothing
Exit_Create60DetailsWorksheet:
Exit Sub
Err_Create60DetailsWorksheet:
MsgBox Err.Number & " - " & Err.Description, vbCritical, "Create60DetailsWorksheet()"
Resume Exit_Create60DetailsWorksheet
End Sub
Thanks in advance for your help!