Open Workbook Using VBA

M

March

Dear All,

I want to open an additional workbook using VBA.

'Where I get file name; This works
txtTradeTrackerFile = ThisWorkbook.Worksheets("Access").Cells(3, 5)

'I don't know how to solve this cause of error in my project
'It works in Access. However, in Excel I really don't know :)
Set xBook = Workbooks.Open(CurrentProject.Path + "\" +
txtTradeTrackerFile)

Please give me suggestion.

Thanks,

March
 
B

Bob Phillips

Set xBook = Workbooks.Open(ThisWorkbook.Path & Application.PathSeparator &
txtTradeTrackerFile)


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
J

Jim Thomlinson

You are close...

txtTradeTrackerFile = ThisWorkbook.Worksheets("Access").Cells(3, 5)

on error resume next
Set xBook = Workbooks.Open(thisworkbook.Path & "\" &
txtTradeTrackerFile)
on error goto 0

if xbook is nothing then
msgbox "the book was not successfully opened"
end if
 
M

March

Thank you so much.

Jim Thomlinson said:
You are close...

txtTradeTrackerFile = ThisWorkbook.Worksheets("Access").Cells(3, 5)

on error resume next
Set xBook = Workbooks.Open(thisworkbook.Path & "\" &
txtTradeTrackerFile)
on error goto 0

if xbook is nothing then
msgbox "the book was not successfully opened"
end if
 
Top