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



All times are GMT +1. The time now is 03:44 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"