Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I stop blank workbook from opening when opening an existing kjg Excel Discussion (Misc queries) 3 February 12th 10 09:36 PM
REALLY easy question Thatgirl Excel Worksheet Functions 2 July 3rd 08 10:22 AM
Easy question for you all holyearth Excel Worksheet Functions 3 May 1st 06 08:00 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM
easy question .... i think Dean Excel Discussion (Misc queries) 1 January 6th 05 06:31 PM


All times are GMT +1. The time now is 01:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"