+ Reply to Thread
Results 1 to 7 of 7

getting a Macro to use a specific cell in spreadsheet as a fiel save name

  1. #1
    Registered User
    Join Date
    03-16-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    12

    getting a Macro to use a specific cell in spreadsheet as a fiel save name

    I created a macro within a workbook that amongst other things, save my spreadsheet as an XLS and PDF document. My problem is that the macro saves the document with the default name "book1"

    What I would like to do as part of the macro is to save the document using data from a specific cell (I.e. client name). Is this possible within a macro environment?

    Thank you in advance for your help.

    Mike

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: getting a Macro to use a specific cell in spreadsheet as a fiel save name

    Can you post the code that you have?

  3. #3
    Registered User
    Join Date
    03-16-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: getting a Macro to use a specific cell in spreadsheet as a fiel save name

    Here you go:

    Sub finalysequote()
    '
    ' finalysequote Macro
    ' create new document, print format, save document as excel sheet on google drive, save quote as pdf document on google drive
    '
    ' Keyboard Shortcut: Ctrl+a
    '
    Range("A1:M72").Select
    Selection.Copy
    Workbooks.Add
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
    .PrintTitleRows = ""
    .PrintTitleColumns = ""
    End With
    Application.PrintCommunication = True
    ActiveSheet.PageSetup.PrintArea = ""
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
    .LeftHeader = ""
    .CenterHeader = ""
    .RightHeader = ""
    .LeftFooter = ""
    .CenterFooter = ""
    .RightFooter = ""
    .LeftMargin = Application.InchesToPoints(0.7)
    .RightMargin = Application.InchesToPoints(0.7)
    .TopMargin = Application.InchesToPoints(0.75)
    .BottomMargin = Application.InchesToPoints(0.75)
    .HeaderMargin = Application.InchesToPoints(0.3)
    .FooterMargin = Application.InchesToPoints(0.3)
    .PrintHeadings = False
    .PrintGridlines = False
    .PrintComments = xlPrintNoComments
    .PrintQuality = 600
    .CenterHorizontally = False
    .CenterVertically = False
    .Orientation = xlPortrait
    .Draft = False
    .PaperSize = xlPaperLetter
    .FirstPageNumber = xlAutomatic
    .Order = xlDownThenOver
    .BlackAndWhite = False
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = 1
    .PrintErrors = xlPrintErrorsDisplayed
    .OddAndEvenPagesHeaderFooter = False
    .DifferentFirstPageHeaderFooter = False
    .ScaleWithDocHeaderFooter = True
    .AlignMarginsHeaderFooter = True
    .EvenPage.LeftHeader.Text = ""
    .EvenPage.CenterHeader.Text = ""
    .EvenPage.RightHeader.Text = ""
    .EvenPage.LeftFooter.Text = ""
    .EvenPage.CenterFooter.Text = ""
    .EvenPage.RightFooter.Text = ""
    .FirstPage.LeftHeader.Text = ""
    .FirstPage.CenterHeader.Text = ""
    .FirstPage.RightHeader.Text = ""
    .FirstPage.LeftFooter.Text = ""
    .FirstPage.CenterFooter.Text = ""
    .FirstPage.RightFooter.Text = ""
    End With
    Application.PrintCommunication = True
    ChDir _
    "C:\Users\Mike's Laptop\Google Drive\Quotes 2013\Final quotes - client copies"
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Users\Mike's Laptop\Google Drive\Quotes 2013\Final quotes - client copies\Book1.xlsx" _
    , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\Mike's Laptop\Google Drive\Quotes 2013\Final quotes - client copies\Book1.pdf" _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True
    End Sub

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: getting a Macro to use a specific cell in spreadsheet as a fiel save name

    In what cell is the client name located?

  5. #5
    Registered User
    Join Date
    03-16-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: getting a Macro to use a specific cell in spreadsheet as a fiel save name

    it is in cell c13

    Thanks

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: getting a Macro to use a specific cell in spreadsheet as a fiel save name

    Maybe:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-16-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: getting a Macro to use a specific cell in spreadsheet as a fiel save name

    Works great! thank you very much for your help John.

    Mike

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: getting a Macro to use a specific cell in spreadsheet as a fiel save name

    You're welcome Mike. Glad to help out, and thanks for the feedback. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: getting a Macro to use a specific cell in spreadsheet as a fiel save name

    You're welcome Mike. Glad to help out, and thanks for the feedback. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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