+ Reply to Thread
Results 1 to 4 of 4

Can't 'SaveAs' Directly to Network Folder

Hybrid View

jbl25 Can't 'SaveAs' Directly to... 07-06-2005, 06:04 PM
Guest Re: Can't 'SaveAs' Directly... 07-06-2005, 08:05 PM
Guest Re: Can't 'SaveAs' Directly... 07-07-2005, 08:05 AM
jbl25 I don't have any foreign... 07-07-2005, 09:36 AM
  1. #1
    Registered User
    Join Date
    03-16-2004
    Posts
    23

    Can't 'SaveAs' Directly to Network Folder

    Hello,
    I'm using the function below to pop up a "Browse for folder" window in order to get a network file path. Later in the code I save the workbook to the path under a new name. If I map a drive directly to the folder I want to save to, I get a run-time 1004 error saying the file cannot be accessed. If I map to the folder one level above where I want to save, then select down a level in the browse window, it works. If I start at the very top level in the browse window and manually select all the way down to the desired location, it also works. Also no problems when saving directly to my computer. I'm running excel 2003 and using Lib shell32.dll. Any ideas why this is happening? Thanks very much for your help!!

    Function GetDirectory(Optional Msg) As String
    Dim bInfo As Browseinfo
    Dim Path As String
    Dim r As Long, X As Long, pos As Integer
    bInfo.pidlroot = 0&
    If IsMissing(Msg) Then
    bInfo.lpsztitle = "Select a folder"
    Else
    bInfo.lpsztitle = Msg
    End If
    bInfo.ulflags = &H1
    X = SHBrowseforfolder(bInfo)
    Path = Space$(512)
    r = SHGetPathFromIDList(ByVal X, ByVal Path)
    If r Then
    pos = InStr(Path, Chr$(0))
    GetDirectory = Left(Path, pos - 1)
    Else
    GetDirectory = ""
    End If
    End Function

  2. #2
    Damon Longworth
    Guest

    Re: Can't 'SaveAs' Directly to Network Folder

    Try changing drives before the save as. See ChDrive Statement in help.



    --
    Damon Longworth

    Don't miss out on the 2005 Excel User Conference
    Sept 16th and 17th
    Stockyards Hotel - Ft. Worth, Texas
    www.ExcelUserConference.com


    "jbl25" <jbl25.1rrqek_1120687529.8926@excelforum-nospam.com> wrote in
    message news:jbl25.1rrqek_1120687529.8926@excelforum-nospam.com...
    >
    > Hello,
    > I'm using the function below to pop up a "Browse for folder" window in
    > order to get a network file path. Later in the code I save the
    > workbook to the path under a new name. If I map a drive directly to
    > the folder I want to save to, I get a run-time 1004 error saying the
    > file cannot be accessed. If I map to the folder one level above where
    > I want to save, then select down a level in the browse window, it
    > works. If I start at the very top level in the browse window and
    > manually select all the way down to the desired location, it also
    > works. Also no problems when saving directly to my computer. I'm
    > running excel 2003 and using Lib shell32.dll. Any ideas why this is
    > happening? Thanks very much for your help!!
    >
    > Function GetDirectory(Optional Msg) As String
    > Dim bInfo As Browseinfo
    > Dim Path As String
    > Dim r As Long, X As Long, pos As Integer
    > bInfo.pidlroot = 0&
    > If IsMissing(Msg) Then
    > bInfo.lpsztitle = "Select a folder"
    > Else
    > bInfo.lpsztitle = Msg
    > End If
    > bInfo.ulflags = &H1
    > X = SHBrowseforfolder(bInfo)
    > Path = Space$(512)
    > r = SHGetPathFromIDList(ByVal X, ByVal Path)
    > If r Then
    > pos = InStr(Path, Chr$(0))
    > GetDirectory = Left(Path, pos - 1)
    > Else
    > GetDirectory = ""
    > End If
    > End Function
    >
    >
    > --
    > jbl25
    > ------------------------------------------------------------------------
    > jbl25's Profile:
    > http://www.excelforum.com/member.php...fo&userid=7225
    > View this thread: http://www.excelforum.com/showthread...hreadid=385073
    >




  3. #3
    NickHK
    Guest

    Re: Can't 'SaveAs' Directly to Network Folder

    jbl25,
    English Excel 2000 cannot save to a network path that contains foreign
    (Chinese) characters, for me anyway.

    NickHK

    "jbl25" <jbl25.1rrqek_1120687529.8926@excelforum-nospam.com> wrote in
    message news:jbl25.1rrqek_1120687529.8926@excelforum-nospam.com...
    >
    > Hello,
    > I'm using the function below to pop up a "Browse for folder" window in
    > order to get a network file path. Later in the code I save the
    > workbook to the path under a new name. If I map a drive directly to
    > the folder I want to save to, I get a run-time 1004 error saying the
    > file cannot be accessed. If I map to the folder one level above where
    > I want to save, then select down a level in the browse window, it
    > works. If I start at the very top level in the browse window and
    > manually select all the way down to the desired location, it also
    > works. Also no problems when saving directly to my computer. I'm
    > running excel 2003 and using Lib shell32.dll. Any ideas why this is
    > happening? Thanks very much for your help!!
    >
    > Function GetDirectory(Optional Msg) As String
    > Dim bInfo As Browseinfo
    > Dim Path As String
    > Dim r As Long, X As Long, pos As Integer
    > bInfo.pidlroot = 0&
    > If IsMissing(Msg) Then
    > bInfo.lpsztitle = "Select a folder"
    > Else
    > bInfo.lpsztitle = Msg
    > End If
    > bInfo.ulflags = &H1
    > X = SHBrowseforfolder(bInfo)
    > Path = Space$(512)
    > r = SHGetPathFromIDList(ByVal X, ByVal Path)
    > If r Then
    > pos = InStr(Path, Chr$(0))
    > GetDirectory = Left(Path, pos - 1)
    > Else
    > GetDirectory = ""
    > End If
    > End Function
    >
    >
    > --
    > jbl25
    > ------------------------------------------------------------------------
    > jbl25's Profile:

    http://www.excelforum.com/member.php...fo&userid=7225
    > View this thread: http://www.excelforum.com/showthread...hreadid=385073
    >




  4. #4
    Registered User
    Join Date
    03-16-2004
    Posts
    23
    I don't have any foreign characters in the path, so I mapped a drive directly to the folder I wish to save in, called Z. I added
    ChDrive "Z"
    right before the SaveAs code, but got the same error. Thanks for your responses, any other ideas? Thanks again.

+ 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