cancel
Showing results for 
Search instead for 
Did you mean: 

Code Stage - PageSetup complier error

YunaLee
Staff
Staff

Hi all!

Following is an excel macro code which is recorded in excel, placed in code stage.
and there are compiler error when we check code.
I'm very new to VB code so if anyone could get me clue to get closer to the resolution, I would really appreciate it.
(Is there possibility that PageSetup related dll is neccesary?) 


Inputs
29610.png

Outputs
29611.png


Code
--------------

 
Dim excel as Object
Dim ws as Object = GetWorksheet(handle, workbookname, worksheetname)
Dim wb as Object = GetWorkbook(handle, workbookname)
 
Dim xlPrintSheetEnd = 1
Dim xlPaperA4 = 9
 
ws.Activate()
wb.Activate()
excel = wb.Application
    excel.PrintCommunication = False
    With ws.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    excel.PrintCommunication = True
    ws.PageSetup.PrintArea = ""
    excel.PrintCommunication = False
    With ws.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = excel.InchesToPoints(0.7)
        .RightMargin = excel.InchesToPoints(0.7)
        .TopMargin = excel.InchesToPoints(0.75)
        .BottomMargin = excel.InchesToPoints(0.75)
        .HeaderMargin = excel.InchesToPoints(0.3)
        .FooterMargin = excel.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintSheetEnd
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 2
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With 

-

Validation
29612.png

Warm Regards
Yuna


------------------------------
Yuna Lee
Solution Consultant
Blue Prism Korea
------------------------------
10 REPLIES 10

Hi, Michael.

Yeah It seems like there is nothing like my idea. 
Thank you for your comfirmation though 🙂

Best Regards



------------------------------
Yuna Lee
Solution Consultant
Blue Prism Korea
------------------------------