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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel GetObject - path unknown

Status
Not open for further replies.

hotbread

Technical User
Mar 13, 2006
42
AU
I need to reference a workbook that is open on the desktop, but the path is unknown. Is there anyway to use the GetObject to reference a workbook based on it's name instead of the full path?

The macro can't do this by looking through the Workbooks collection because the open workbook is usually in a different instance of Excel from the one the macro is running from.
 
Use "Alt"-"F11" to open the VBA editor and in the workbook open event enter this (Or some other means to fire an event, macro or ??

See if that will work.

Code:
Private Sub Workbook_Open()

MsgBox Me.Path & "\" & Me.Name

End Sub

End Sub
 

GetObject shall grabe the instance of excel running, so play with the names of open workbooks to find yours.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top