Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem accessing Excel named range from Access VBA

Status
Not open for further replies.

gpseymour

Technical User
Oct 25, 2002
3
US
Folks...

I'm having trouble using the .GoTo method of an Excel object. Can someone advise me? I've tried several methods, and all receive the following error: "Error 1004: Method 'Goto' of object '_Application' failed."

Here are two of the attempts:


EXAMPLE 1:

Dim xl As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet

Dim strFile As String
Dim booXLOpen As Boolean
Dim intNameCounter As Integer

booXLOpen = True
Set xl = GetObject(, "Excel.application")
xl.Visible = False


'strFile has been assigned a value from a table
Set wb = GetObject(strFile)

wb.Application.Goto Reference:=wb.Names(intNameCounter)




------------------
EXAMPLE 2:

(This changes only the last line to the following

'retrieve top-left cell location from named range
'this is within a loop, based on intNameCounter
intColonPosition = InStr(wb.Names _
(intNameCounter).RefersToR1C1Local, ":")
strTopLeftCell = Mid(wb.Names _
(intNameCounter).RefersToR1C1Local, _
intBangPosition + 1, intColonPosition - _
(intBangPosition + 1))

wb.Application.Goto Reference:=strTopLeftCell

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top