DoCmd.OutputTo AcFormatPDF

moishy

Registered User.
Local time
Today, 03:40
Joined
Dec 14, 2009
Messages
264
Hello all Experts,

I'm trying to use DoCmd.OutputTo to save a report as a PDF file. The trouble I'm having is that it seems to ignore the formatting set in VBA. In this case if a certain condition is true the PageHeader is hidden, the problem is that DoCmd.OutputTo prints that header even if the condition is true.

Is there a way around it? Am I missing something?

Thanks in advance for your attention.
 
In the PageHeader_Format.

Here it is:
Code:
Private Sub Section_PageHeader_Format(Cancel As Integer, FormatCount As Integer)
    'Display the page header on all pages but the first of each group
    'idea from: [URL]http://www.utteraccess.com/forum/Page-Header-Page-Deta-t1966472.html&p=2111636#entry2111636[/URL]
    'Another option is:
    'Create a group count using the Running Sum property of a textbox. Hide the Page Header if the value is 1.
    
    intCurGrp = Int(Me.txtID) 'txtID (.visible=false) holds the current group id
    If intCurGrp = intTmpGrp Then
        Me.Section_PageHeader.Visible = True
    Else
        Me.Section_PageHeader.Visible = False
    End If
    intTmpGrp = intCurGrp
End Sub
 
If I remember correctly (and I might not) you need to open the report first and then do the outputTo. You can open it hidden though and then close it when done so nobody needs to be the wiser.
 
I tried that and unfortunately it doesn't make a difference, it still ignores the vba.
 
Sorry, don't know what to tell you. Where I work we use code to do an actual print to PDF and that does exactly as if it was being previewed.
 
I guess that's what I'll have to do too.

I was thinking of automating PDFCreator, what do you use?
 
I should have trusted you. After developing automation for two different virtual printers, I discovered that the formatting I wanted was only applied if the report was open (like you said) in AcViewPreview, now that I think about it, it makes lots of sense.

So it turns out that the automation is only necessary for backwards compatibility.
 

Users who are viewing this thread

Back
Top Bottom