Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy Question - Opening a workbook
Greg, try this:
Sub demo() Dim strPath As String Dim wbW As Workbook 'get path and name of workbook containing macro strPath = ThisWorkbook.FullName 'extract path only strPath = Left(strPath, InStrRev(strPath, "\")) 'open another workbook to this folder: Set wbW = Workbooks.Open(strPath & "MyBook.xls") End Sub Note that if the workwork containing the code has not been saved yet then the second strPath statement will return "" and you'll get an error openning the workbook. Cheers, Dave. -----Original Message----- Hi, I need to know the syntax for opening a workbook in the same folder from which the workbook running the macro is in. The overall path of the files will change but they will always be in the same folder. Thanks in advance Greg . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I stop blank workbook from opening when opening an existing | Excel Discussion (Misc queries) | |||
REALLY easy question | Excel Worksheet Functions | |||
Easy question for you all | Excel Worksheet Functions | |||
new user with easy question? not easy for me | New Users to Excel | |||
easy question .... i think | Excel Discussion (Misc queries) |