ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Relative path (https://www.excelbanter.com/excel-programming/392547-relative-path.html)

Perico[_2_]

Relative path
 
How do I specify a relative path in vba, to assign to a variable?

Dave Peterson

Relative path
 
Relative to what?

Maybe...

Dim myPath as string
dim myPathParent as string

mypath = "C:\my documents\excel\test"
mypathparent = mypath & "\.."

Watch out for that backslash. Include it only one location.



Perico wrote:

How do I specify a relative path in vba, to assign to a variable?


--

Dave Peterson

Chip Pearson

Relative path
 
It isn't clear what you are trying to accomplish, but you can use "..\" to
get a parent folder. E.g.,

ChDir "C:\Test\Sub1\SubSub1"
Debug.Print Dir("..\..\Sub1\Test.txt", vbNormal)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Perico" wrote in message
...
How do I specify a relative path in vba, to assign to a variable?




All times are GMT +1. The time now is 11:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com