+ Reply to Thread
Results 1 to 5 of 5

Saving file issue

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-28-2003
    Location
    Happyville, USA
    MS-Off Ver
    365
    Posts
    300

    Saving file issue

    Hello all,

    The code below saves the file to a network drive.

    PHP Code: 
        ActiveWorkbook.SaveAs Filename:= _
            
    "Q:\Logistics\Team Logistics\PURA upload sheet\PURA upload sheet.xls"_
            FileFormat
    :=xlNormalPassword:=""WriteResPassword:=""_
            ReadOnlyRecommended
    :=FalseCreateBackup:=False 
    It has worked great but all the sudden new employees have an "S" not a "Q" in front of the first character of the code. The macro breaks if a new employee uses it. Is there a way I can have it save to either "S" or "Q" in the first line of the code? Or is there another way around this problem?

    Thank you so much in advance for time.

    Eddie

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Saving file issue

    Maybe try:
    ActiveWorkbook.SaveAs Filename:= _ 
            iif(dir("Q:\") <> "","Q","S") & ":\Logistics\Team Logistics\PURA upload sheet\PURA upload sheet.xls", _ 
            FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ 
            ReadOnlyRecommended:=False, CreateBackup:=False
    not tested though.

  3. #3
    Forum Contributor
    Join Date
    10-28-2003
    Location
    Happyville, USA
    MS-Off Ver
    365
    Posts
    300

    Re: Saving file issue

    Thank you so much for your quick reply. I'll test it when I get out of my meeting.

    One question: Should the first line of the code start with "iif"? It looks like a typo but it could also be something that I haven't tripped across yet.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,698

    Re: Saving file issue

    This occurs when you have network drives set up with different "short cuts." Find out the UNC from your IT department and change your VBA to reflect the actual name of the server and not the file path pseudonym.

    This extract may be helpful

    Uniform Naming Convention[edit source | editbeta]

    The Microsoft Windows UNC, short for Universal Naming Convention or Uniform Naming Convention, specifies a common syntax to describe the location of a network resource, such as a shared file, directory, or printer. The UNC syntax for Windows systems has the generic form:
    \\ComputerName\SharedFolder\Resource
    Microsoft often refers to this as a "network path".
    Some Microsoft Windows interfaces also allow or require UNC syntax for WebDAV share access, rather than a URL. The UNC syntax is extended[2] with optional components to denote use of SSL and TCP/IP port number, a WebDAV URL of http[s]://HostName[:Port]/SharedFolder/Resource becomes
    \\HostName[@SSL][@Port]\SharedFolder\Resource
    Note: The UNC syntax sometimes appears written with slashes. Microsoft Windows treats slashes and back slashes in this context as equivalent (mostly).
    When viewed remotely, the "SharedFolder" may have a name different from what a program on the server sees when opening "\SharedFolder". Instead, the SharedFolder name consists of an arbitrary name assigned to the folder when defining its "sharing".
    Some Microsoft Windows interfaces also accept the "Long UNC":
    \\?\UNC\ComputerName\SharedFolder\Resource
    Microsoft Windows uses the following types of paths:
    local file system (LFS), such as C:\File
    uniform naming convention (UNC), such as \\Server\Volume\File or /<internet resource name>[\Directory name] (at least in Windows 7 and later)
    long UNC or UNCW, such as \\?\C:\File or \\?\UNC\Server\Volume\File
    In versions of Windows prior to Windows XP, only the APIs that accept "Long UNC" could accept more than 260 characters.
    The shell in Windows XP and Windows Vista, explorer.exe, allows path names up to 248 characters long.
    Since UNCs start with two backslashes, and the backslash is also used for string escaping and in regular expressions, this can result in extreme cases of leaning toothpick syndrome: an escaped string for a regular expression matching a UNC begins with 8 backslashes – \\\\\\\\ – because the string and regular expression both requires escaping. This can simplified by using raw strings, as in C#: @"\\\\".
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Contributor
    Join Date
    10-28-2003
    Location
    Happyville, USA
    MS-Off Ver
    365
    Posts
    300

    Re: Saving file issue

    Thank you so much. The code worked great.

    Eddie

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Issue with automatically saving a file to a folder on my desktop
    By pcm034 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2013, 01:39 PM
  2. Saving Issue
    By cmm5350 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2012, 10:16 AM
  3. Creating a .txt file extracting information from a Excel file saving as .resx file
    By AbdallahHajbed in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-19-2012, 09:00 AM
  4. saving issue
    By sannndrad in forum Excel General
    Replies: 0
    Last Post: 11-24-2011, 05:06 AM
  5. Excel 2007 : format issue when saving the csv file
    By mls_newbee in forum Excel General
    Replies: 0
    Last Post: 09-22-2010, 12:20 PM

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