- Joined
- Oct 24, 2016
- Messages
- 2
- Reaction score
- 0
I have been having a similar issue with trying to define a print area. the area i need to print changes with each time i refresh the data.
Currently i have set a print area manually but this wont work when i start getting more data.
I need to add/change my code in someway so that it only prints the pages of the worksheet which have data in them.
Annoyingly each page of the sheet is a table and so has headers for each column which any function would, i assume, class as data and so i only want them to print if the table gas data.
The good news is that if the first row in the table has data in then i need that whole page printed anyway.
my current code is:
Dim PathString As String
Sub Print_ActionManager_1_RecentActivityReport()
Application.ScreenUpdating = False
Sheets("Districts").Select
Range("A2").Select
While Not ActiveCell.Value = Empty
Sheets("RecentActivityReport").Range("N1").Value = ActiveCell.Value
Sheets("RecentActivityReport").Select
'Call ChangeGraphAxis
Range("A4").Select
Sheets("RecentActivityReport").Select
Application.StatusBar = "Executing - Please be patient..."
Call Print_To_File3(Sheets("RecentActivityReport").Range("N1").Value)
Application.StatusBar = False
Sheets("Districts").Select
ActiveCell.Offset(1, 0).Select
Wend
Sheets("RecentActivityReport").Select
Application.ScreenUpdating = True
Sheets("RecentActivityReport").Select
Range("A3").Select
MsgBox "All Completed, Please check Files!"
End Sub
Function Print_To_File3(Districts As String)
'PathString = "\\Ascurbansci11\GM\GME\S4 Navigate\Action Manager\Reports\France\Reporting\DistrictReports\1_RecentActivityReport" & DealerGroup & ".pdf"
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, PrintToFile:=True, PrToFileName:=PathString
CurrentDir = ActiveWorkbook.Path
Application.DisplayAlerts = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
CurrentDir & "\Reporting\DistrictReports\1_RecentActivityReport\District_Action_Report_" & Districts & "_1_RecentActivityReport_" & Format(Now, "dd-mm-yy") _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Application.DisplayAlerts = True
End Function
any help would be much appreciated.
Currently i have set a print area manually but this wont work when i start getting more data.
I need to add/change my code in someway so that it only prints the pages of the worksheet which have data in them.
Annoyingly each page of the sheet is a table and so has headers for each column which any function would, i assume, class as data and so i only want them to print if the table gas data.
The good news is that if the first row in the table has data in then i need that whole page printed anyway.
my current code is:
Dim PathString As String
Sub Print_ActionManager_1_RecentActivityReport()
Application.ScreenUpdating = False
Sheets("Districts").Select
Range("A2").Select
While Not ActiveCell.Value = Empty
Sheets("RecentActivityReport").Range("N1").Value = ActiveCell.Value
Sheets("RecentActivityReport").Select
'Call ChangeGraphAxis
Range("A4").Select
Sheets("RecentActivityReport").Select
Application.StatusBar = "Executing - Please be patient..."
Call Print_To_File3(Sheets("RecentActivityReport").Range("N1").Value)
Application.StatusBar = False
Sheets("Districts").Select
ActiveCell.Offset(1, 0).Select
Wend
Sheets("RecentActivityReport").Select
Application.ScreenUpdating = True
Sheets("RecentActivityReport").Select
Range("A3").Select
MsgBox "All Completed, Please check Files!"
End Sub
Function Print_To_File3(Districts As String)
'PathString = "\\Ascurbansci11\GM\GME\S4 Navigate\Action Manager\Reports\France\Reporting\DistrictReports\1_RecentActivityReport" & DealerGroup & ".pdf"
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, PrintToFile:=True, PrToFileName:=PathString
CurrentDir = ActiveWorkbook.Path
Application.DisplayAlerts = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
CurrentDir & "\Reporting\DistrictReports\1_RecentActivityReport\District_Action_Report_" & Districts & "_1_RecentActivityReport_" & Format(Now, "dd-mm-yy") _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Application.DisplayAlerts = True
End Function
any help would be much appreciated.