+ Reply to Thread
Results 1 to 4 of 4

change curdir to a folder on a network

  1. #1
    richardconers@yahoo.com
    Guest

    change curdir to a folder on a network

    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!


  2. #2
    Jim May
    Guest

    Re: change curdir to a folder on a network

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

    "\\Newton\c\FolderIWant\"

    Give that I try..
    HTH

    <richardconers@yahoo.com> wrote in message
    news:1128879880.457798.263580@z14g2000cwz.googlegroups.com...
    >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!
    >




  3. #3
    Bob Phillips
    Guest

    Re: change curdir to a folder on a network

    Richard,

    Try this

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


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


    --
    HTH

    Bob Phillips

    <richardconers@yahoo.com> wrote in message
    news:1128879880.457798.263580@z14g2000cwz.googlegroups.com...
    > 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!
    >




  4. #4
    Registered User
    Join Date
    02-11-2020
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    1

    Re: change curdir to a folder on a network

    works perfectly in my excel 2016. thank you very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1