+ Reply to Thread
Results 1 to 9 of 9

how to specify a file save path to a save macro

  1. #1
    Registered User
    Join Date
    02-01-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    45

    how to specify a file save path to a save macro

    I have a working macro which save to documents folder, I have tryed without success to modify this to save to a desktop folder or even a "C:\" drive folder.

    working VBA Code
    Please Login or Register  to view this content.
    Failing code
    Please Login or Register  to view this content.
    Any help please!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: how to specify a file save path to a save macro

    Hi,


    What does Range("DriverName") equate to?



    And are you sure it's failing on the 'FileName = ' line or does it fail on the following line?

    I ask since I had exactly this problem earlier this week - see thread

    http://www.excelforum.com/excel-prog...ml#post3425557

    which may help you.
    Last edited by Richard Buttrey; 10-04-2013 at 12:21 PM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-01-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: how to specify a file save path to a save macro

    Range("DriverName") is a cell containing a drivers name.
    when I add "C:\" & to the FileName= line, the following line fails, but the following line of course does point to the file name.

    thanks.

  4. #4
    Registered User
    Join Date
    02-01-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: how to specify a file save path to a save macro

    I think my confusion is between the FILE PATH and FILE NAME.

    Im not sure how to set a FILE PATH into my code. I think im trying to add "C:\" into the file name, which of course wont work.

    Any help with this please..

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: how to specify a file save path to a save macro

    ...but as I said, what is the Range("DriverName") evaluating to in VBA?

    i.e. what do you see when you hover over it?

    There's nothing wrong with adding any string before it, but if the range also contains the string "C:\" then obviously the code won't understand "C:\C:\"

  6. #6
    Registered User
    Join Date
    02-01-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: how to specify a file save path to a save macro

    Range("driver name"), is D.stanley or r.jones ect.
    This also. fails with string "rota/" &

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: how to specify a file save path to a save macro

    Hi,

    Time to upload the workbook so that we can see your problem in context.

  8. #8
    Registered User
    Join Date
    02-01-2012
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: how to specify a file save path to a save macro

    If anyone could make this attached macro work, I would be SOO grateful.

    'Remove "rota\" & and this run good, or just even remove the \ and it runs.

    Thanks!
    Attached Files Attached Files

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: how to specify a file save path to a save macro

    Hi

    FileName = "C:\" & Range("DriverName") & " " & " 29th September 2013"

    works just fine for me.

    Are you sure you actually have a "C:\" drive path?

+ 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. Replies: 1
    Last Post: 09-05-2013, 02:39 PM
  2. [SOLVED] VBA for file save as macro enabled to a specifi path and folders
    By stpeter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2013, 03:41 PM
  3. Macro to save sheet as CSV using a dynamic file name and file path
    By chris.tinta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2013, 10:45 AM
  4. Replies: 5
    Last Post: 03-21-2013, 07:34 AM
  5. Save As in a certain file path
    By Macro1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-18-2011, 07:11 AM

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