change curdir to a folder on a network

R

richardconers

I would like VBA to change the folder that is displayed when using the
(workbook) OPEN dialog box to a folder that resides on a network
drive/computer.

let's say the file open dialog box opens to
"C:\OldFolder" (and curdir displays "C:\OldFolder" )

let's say I want the file open dialog box to display a folder on a
network "\\Newton\c\FolderIWant"

chdrive "\\Newton\c" doesn't work
chdir "\\Newton\c\FolderIWant" " doesn't work

and

Application.DefaultFilePath = "\\Newton\c\FolderIWant"
msgbox Application.DefaultFilePath
does give me "\\Newton\c\FolderIWant" [in the message box]
HOWEVER
neither curdir nor file open dialog box changes to
"\\Newton\c\FolderIWant"

They both still are on "C:\OldFolder"
What do I do?????
Thank you!
 
J

Jim May

I've seen the need to included A LAST "\" in the Path reference,, like:

"\\Newton\c\FolderIWant\"

Give that I try..
HTH
 
B

Bob Phillips

Richard,

Try this

Private Declare Function SetCurrentDirectoryA _
Lib "kernel32" (ByVal lpPathName As String) As Long


Sub SetUNCPath()
SetCurrentDirectoryA "\\Newton\c\FolderIWant"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top