Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 21st, 2015, 10:32 PM
Registered User
 
Join Date: Dec 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Gilcano3
Question Printing Range overlapping headers

Hello everyone I'm new to the FORUM an recently bought the book EXCEL VBA 24hr Trainer 2nd Edition and I'm learning VBA a lot. I'm a Maintenance Supervisor and I'm creating a Worksheet to capture all the repairs in my building also I'm using VBA to create userforms for Data Entry, Search and Printing the Worksheet.

At the moment the Worksheet has 350 rows of information so If a User wants to print just some information it can be done through VBA.

I'm Printing a range called Filter_Stuff after I created a PDF but the printing area is overlapping the Headers. I don't know what I'm doing wrong
This is my code:
http://i280.photobucket.com/albums/k...pstapiyfjd.jpg

http://i280.photobucket.com/albums/k...psjpfugzwm.jpg


Code:
 
Sub PrintPDFAll()
'*******************
'turn off screen updating
Dim Opendialog
Dim MyRange As Range
Application.ScreenUpdating = False
FolderPath = Application.ActiveWorkbook.Path

'open dialog and set file type
Opendialog = Application.GetSaveAsFilename("", filefilter:="PDF Files (*.pdf), *.pdf", _
Title:="My Data")
'if no value is added for file name
If Opendialog = False Then
MsgBox "The operation was not successful"
Exit Sub
End If
'set the named range for the PDF print area
Sheet1.Select
With Sheet1
.Range("AS1:BI" & Cells(Rows.Count, "AS").End(xlUp).Row).Name = "Filter_Stuff"
End With
'set range
Set MyRange = Sheet1.Range(" Filter_Stuff ")
With Sheet1.PageSetup
     .PrintArea = "Filter_Stuff"
     .LeftHeader = "&""Bold""&20CCBQ - Peter J. Striano"
     .CenterHeader = "Page &P of &N"
     .RightHeader = "Printed &D &T"
     .LeftFooter = "Path : " & FolderPath               'ActiveWorkbook.Path"
     .CenterFooter = "Workbook Name: &F"
     .RightFooter = "Sheet: &A"
End With

'create the PDF
On Error Resume Next
MyRange.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Opendialog, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
'error handler
On Error GoTo 0
'clear the page breaks
ActiveSheet.DisplayPageBreaks = False
Application.ScreenUpdating = False
Sheet1.Select
End Sub
 
Old December 22nd, 2015, 06:29 PM
Registered User
 
Join Date: Dec 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Gilcano3
Default Got it

I got it, needed to include this in the PageSetup


Code:
.HeaderMargin = Application.InchesToPoints(0.5)
        .TopMargin = Application.InchesToPoints(0.6)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Other controls are overlapping AJAX calendar saket123 ASP.NET 2.0 Basics 5 August 13th, 2008 08:03 AM
Overlapping Images in Word vengatatindia Word VBA 0 February 12th, 2008 08:43 AM
Overlapping id's problem Gert SQL Server 2005 4 May 26th, 2006 03:55 AM
overlapping child control-problem pazzuzu Visual C++ 2 November 28th, 2005 04:17 AM
xsl:template match 'overlapping' ? Kabe XSLT 1 February 25th, 2005 06:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.