![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
|
I basically want the variable wkbname to act as a directory e.g
Workbooks.Open Filename:="c:directoryDays Cover.xls" this is what I have it doesn't work any help? GetDirPath_ThisWorkbook (wkbname) ChDir (wkbname) Workbooks.Open Filename:=wkbname"Days Cover.xls" Public wkbname Function GetDirPath_ThisWorkbook(wkbname) As String 'Returns the path from a filespec Dim x As Variant x = Split(ThisWorkbook.FullName, Application.PathSeparator) ReDim Preserve x(0 To UBound(x) - 1) GetDir_ThisWorkbook = Join(x, Application.PathSeparator) & Application.PathSeparator wkbname = GetDir_ThisWorkbook End Function |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: London, UK
Posts: 167
|
Try:
Workbooks.Open Filename:=wkbname & "Days Cover.xls" or you may need to add a slash if the variable wkbname does not end in one. |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
|
thats great thanks I had two &'s and thats why it wouldn't work thanks heaps
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|