Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how can I ..... ?
I have in Sheet1 in A1 the following
= "\\SharedDocs\Test01" in A2 = "\\SharedDocs\Test02" How can I in the code assign a variable to chage to that directory Now what I have to change the directory is: ChDir "\\SharedDocs\Test01 " but I want to have something like that : ChDir "variable" (what it is in A1 for example) thanks a lot emma |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
how can I ..... ?
Emma,
The following will call ChDir to use whatever is in A1: ChDir ActiveSheet.Range("A1").Text You can also use a variable to do this. E.g., Dim S As String S = "\\SharedDocs\Test01 " ChDir S -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "emma" wrote in message ... I have in Sheet1 in A1 the following = "\\SharedDocs\Test01" in A2 = "\\SharedDocs\Test02" How can I in the code assign a variable to chage to that directory Now what I have to change the directory is: ChDir "\\SharedDocs\Test01 " but I want to have something like that : ChDir "variable" (what it is in A1 for example) thanks a lot emma |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
how can I ..... ?
Does chdir work with
ChDir "\\SharedDocs\Test01 " If so, then Chip gave you the answer, but in my experience, it does not work with a UNC path. Previously posted by Rob Bovey - place in the top of a general/standard module: Private Declare Function SetCurrentDirectoryA Lib _ "kernel32" (ByVal lpPathName As String) As Long Sub ChDirNet(szPath As String) Dim lReturn As Long lReturn = SetCurrentDirectoryA(szPath) Debug.Print lReturn If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path." End Sub Sub FindFile() Usage would be like this: ChDirNet "\\LOGD0FILES\OGILVTW\Docs\Temp" Application.Dialogs(xlDialogFindFile).Show End Sub -- Regards, Tom Ogilvy "emma" wrote in message ... I have in Sheet1 in A1 the following = "\\SharedDocs\Test01" in A2 = "\\SharedDocs\Test02" How can I in the code assign a variable to chage to that directory Now what I have to change the directory is: ChDir "\\SharedDocs\Test01 " but I want to have something like that : ChDir "variable" (what it is in A1 for example) thanks a lot emma |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|