Results 1 to 3 of 3

Report Printing Macro Help

Threaded View

  1. #1
    Registered User
    Join Date
    04-03-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Report Printing Macro Help

    I am very new to Macros and VBA and this is my first post on the forum so please forgive me if it is in the wrong place.

    I am trying to use a macro in excel 2010 to save over 300 individual quarterly reports as independently named PDFs for our clients. This macro should select a name from a data validation list in cell G1, which populates the reports, and then save an array of sheets as a pdf. I would like for it to name the pdf file using the value in G1.


    This is the code I am using to print and save the PDF files.
    ' code to slect sheets to print and set them as the active sheets
        Sheets(Array("A", "B", "C", "D", "E")).Select
        Sheets("A").Activate
        ChDir "C:\Users\JD\Desktop\Reports" ' code for where to save the pdf reports
    ' the following is the code to save the reports as pdf documents
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "C:\Users\JD\Desktop\Reports\" & Range("G1").Value & ".pdf", Quality:= _
            xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
    I believe the the save function works but what I cannot figure out is how to get the macro to cycle through the data validation list giving enough time to populate each client's quarterly report before printing it. Each time I try it only prints one and never changes the value in cell G1 I tried to add some time delays but they did not help at all.

    Thanks for any help you can give me.

    My entire code albeit wrong:

    Sub printing()
        Dim c As Range
        For Each c In Range("A2:A341")
            Range("g1") = c
            Application.Calculate
             'here the name of the module which does the printing
          newHour = Hour(Now())
          newMinute = Minute(Now())
          newSecond = Second(Now()) + 5
          waitTime = TimeSerial(newHour, newMinute, newSecond)
          Application.Wait waitTime
    ' code to slect sheets to print and set them as the active sheets
    
        Sheets(Array("A", "B", "C", "D", "E")).Select
        Sheets("A").Activate
        
        ChDir "C:\Users\JD\Desktop\Reports" ' code for where to save the pdf reports
    ' the following is the code to save the reports as pdf documents
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "C:\Users\JD\Desktop\Reports\" & Range("G1").Value & ".pdf", Quality:= _
            xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
            
            newHour = Hour(Now())
          newMinute = Minute(Now())
          newSecond = Second(Now()) + 3
          waitTime = TimeSerial(newHour, newMinute, newSecond)
          Application.Wait waitTime
          
          Sheets(Control).Select
          
        Next
        MsgBox "You're done!"
    End Sub
    Last edited by jdevans8899; 04-04-2012 at 09:50 AM. Reason: add code designations

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