Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 21st, 2015, 10:32 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2015
Location: NYC
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
Reply With Quote
  #2 (permalink)  
Old December 22nd, 2015, 06:29 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2015
Location: NYC
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)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:33 AM.


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