Reputation: 101
I want to open the folder before the current Directory each time. I tried "..\" but it didn't work, can you help me with that N
ThecurrentDirectory= fso.GetParentFolderName(objFile)
Set myWorkBook = myxlApplication.Workbooks.Open( ThecurrentDirectory & "\..\CLIENTS.xlsx" )
Upvotes: 0
Views: 55
Reputation:
If objFile is a file object then you can chain it's ParentFolder property together multiple times to get the disred result:
Dim fso, f
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
Set objFile = fso.GetFile("C:\Users\best buy\Downloads\stackoverfow\test.xlsm")
Output:
Upvotes: 1
Reputation: 895
Just pack the ThecurrentDirectory in another fso.GetParentFolderName.
ThecurrentDirectory= fso.GetParentFolderName(objFile)
Set myWorkBook = myxlApplication.Workbooks.Open( fso.GetParentFolderName(ThecurrentDirectory) & "\CLIENTS.xlsx" )
Upvotes: 0