+ Reply to Thread
Results 1 to 7 of 7

VBA to save to location and filename in a Cell

  1. #1
    Registered User
    Join Date
    01-19-2023
    Location
    Lincoln
    MS-Off Ver
    365
    Posts
    3

    VBA to save to location and filename in a Cell

    When I run this it saves to the Location that's in cell Z2 but saved it with filename as FALSE, any ideas what's wrong with my code ???

    In cell Z2 it has location with filename at the end which will show current date "C:\Users\me\Documents\File Name 19-01-23.pdf"
    Please Login or Register  to view this content.
    Last edited by davesexcel; 01-19-2023 at 03:58 PM. Reason: code tags required for vba code

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: VBA to save to location and filename in a Cell

    What is in Z2 exactly.

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA to save to location and filename in a Cell


    Just remove saveLocation = which has no sense after Filename = ‼

  4. #4
    Registered User
    Join Date
    01-19-2023
    Location
    Lincoln
    MS-Off Ver
    365
    Posts
    3
    Quote Originally Posted by davesexcel View Post
    What is in Z2 exactly.
    Cell z2 contains the location I want the PDF saving to. So it’s the file location & file name including date and time

  5. #5
    Registered User
    Join Date
    01-19-2023
    Location
    Lincoln
    MS-Off Ver
    365
    Posts
    3
    Quote Originally Posted by Marc L View Post

    Just remove saveLocation = which has no sense after Filename = ‼
    I revised as suggested (see below ) and it wouldn’t Run

    Sub Create_Shift_PDF()
    '
    ' Create_Shift_PDF Macro
    ' Will Save Current Data as a PDF Form
    '
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ Sheets("Shift Brief").Range("z2").Value _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True
    End Sub

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: VBA to save to location and filename in a Cell

    Quote Originally Posted by Dazzybe View Post
    Cell z2 contains the location I want the PDF saving to. So it’s the file location & file name including date and time
    I believe he wanted to know exactly what's in the cell, not a description of it.
    Your problem may lie in the date or time portion of what's in the cell.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA to save to location and filename in a Cell


    According to post #5 you forgot to remove the underscore after Filename …

+ 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. Save Worksheet as Excel & PDF with Filename & Location specified in a cell
    By vikrampnz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-20-2020, 07:51 AM
  2. MACRO - Save Filename & Location based on Cell value
    By acerlaptop in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-14-2020, 05:57 AM
  3. Automate IE11 Save As with save location and filename
    By dband in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2017, 06:11 AM
  4. Save as macro with location and filename
    By realrookie in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-21-2015, 10:16 AM
  5. [SOLVED] macro to 'save as pdf' that prompts for filename, location AND only prints specified range
    By mtcolombo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-06-2013, 01:49 PM
  6. [SOLVED] [Help]macro to open file browser, to select a location, and save the location to a cell
    By zhuleijia in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-06-2013, 09:56 AM
  7. macro to save sheet from workbook. Specified location and filename
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2011, 11:47 PM

Tags for this Thread

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