Excel忽略VBA打印设置

时间:2016-11-08 10:00:35

标签: excel vba excel-vba printing

出于某种原因,Excel忽略了我的" Fit 1 by 1"这里统治。我试着调整缩放,但我做的任何事情似乎都不起作用。任何想法都是最受欢迎的!谢谢!

Private Sub CommandButton1_Click()
Dim Sel_Manager As String
'Specify headers to be repeated at the top
With ActiveSheet.PageSetup
        .PrintTitleRows = "$5:$9"
        .PrintTitleColumns = "$B:$M"
        .Orientation = xlLandscape
        .Zoom = 70
        .FitToPagesWide = 1
        .FitToPagesTall = 1
End With

'Manager selection through simple Inputbox
 Sel_Manager = ComboBox1
'Insert autofilter for worksheet
Cells.Select
Selection.AutoFilter
'Select manager defined in inputbox
ActiveSheet.Range("B14", Range("M14").End(xlDown)).AutoFilter Field:=1, Criteria1:=Sel_Manager
 'Select range to be printed and specify manager in filename
ActiveSheet.Range("B14", Range("M14").End(xlDown)).Select

Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Sel_Manager + ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True

  ActiveSheet.ShowAllData

End Sub

1 个答案:

答案 0 :(得分:0)

适合页面和缩放彼此排除。尝试设置:

    SELECT 
    COUNT(sub.id) AS count,
    DATE(sub.REQUEST_DATE_TIME) AS transaction_date,
    sub.SYSTEM_OWNER,
    sub.transaction_name,
    sub.response,
    MIN(sub.response_time),
    MAX(sub.response_time),
    AVG(sub.response_time),
    sub.channel
FROM
    (SELECT 
        id,
            REQUEST_DATE_TIME,
            RESPONSE_DATE_TIME,
            TIMESTAMPDIFF(SECOND, REQUEST_DATE_TIME, RESPONSE_DATE_TIME) AS response_time,
            SYSTEM_OWNER,
            transaction_name,
            (CASE
                WHEN response_code IN ('0' , '00', 'EIL000') THEN 'Success'
                ELSE 'Failure'
            END) AS response,
            channel
    FROM
        logs
    WHERE
        response_code != ''
            AND DATE(REQUEST_DATE_TIME) BETWEEN '2016-10-26 00:00:00' AND '2016-10-27 00:00:00'
            AND SYSTEM_OWNER != '') sub
GROUP BY DATE(sub.REQUEST_DATE_TIME) , sub.channel , sub.SYSTEM_OWNER , sub.transaction_name , sub.response
ORDER BY DATE(sub.REQUEST_DATE_TIME) DESC , sub.SYSTEM_OWNER , sub.transaction_name , sub.response DESC;