Open Workbook Using VBA

  • Thread starter Thread starter March
  • Start date Start date
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
 
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)
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top