Results 1 to 11 of 11

Compile Error Expected Function or Variable

Threaded View

  1. #1
    Registered User
    Join Date
    01-10-2014
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    57

    Compile Error Expected Function or Variable

    Hi,

    I'm fairly new to VBA so please bare with me. I've basically created this macro which print screens and saves the file into pdf looking up which sheet and range in a tab that i created. I'm however getting this compile error with the "Sub test()" turning yellow:

    Sub test()
    '
    ' test Macro
    '
    
    '
         i = 4
    
    Do
        Sheet35.Select
        sTab = Cells(i, 3).Value
        sPrintRange = Cells(i, 4).Value
        sName = Cells(i, 5).Value
        Sheets.Select = sTab
        Range("A2:R44").Select
        ActiveSheet.PageSetup.PrintArea = sPrintRange
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .PrintTitleRows = ""
            .PrintTitleColumns = ""
        End With
        Application.PrintCommunication = True
        ActiveSheet.PageSetup.PrintArea = sPrintRange
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .LeftHeader = ""
            .CenterHeader = ""
            .RightHeader = ""
            .LeftFooter = ""
            .CenterFooter = ""
            .RightFooter = ""
            .LeftMargin = Application.InchesToPoints(0.708661417322835)
            .RightMargin = Application.InchesToPoints(0.708661417322835)
            .TopMargin = Application.InchesToPoints(0.78740157480315)
            .BottomMargin = Application.InchesToPoints(0.748031496062992)
            .HeaderMargin = Application.InchesToPoints(0.31496062992126)
            .FooterMargin = Application.InchesToPoints(0.31496062992126)
            .PrintHeadings = False
            .PrintGridlines = False
            .PrintComments = xlPrintNoComments
            .PrintQuality = 600
            .CenterHorizontally = False
            .CenterVertically = False
            .Orientation = xlLandscape
            .Draft = False
            .PaperSize = xlPaperA4
            .FirstPageNumber = xlAutomatic
            .Order = xlDownThenOver
            .BlackAndWhite = False
            .Zoom = False
            .FitToPagesWide = 1
            .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
        Application.PrintCommunication = True
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "H:\1- Monthly Financials\2014\5- May\10- Management Information Pack\PDF repository\" & sName & ".pdf" _
            , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
            :=False, OpenAfterPublish:=False
            Sheet35.Select
            i = i + 1
     Loop While i < 6
     
    End Sub
    Any ideas?
    Last edited by shiser; 05-22-2014 at 09:19 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Compile error: Expected variable or procedure, not module
    By kaseyleigh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2015, 03:46 PM
  2. [SOLVED] Compile error expected function or variable (on protect method)
    By Tirren in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-30-2013, 03:22 PM
  3. Mac issue (please help) "Compile error: Expected Function or variable"
    By m1notaur in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-22-2011, 06:00 PM
  4. Compile Error:- expected function or variable problem
    By skin.uk1 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-08-2011, 02:56 PM
  5. [SOLVED] Compile error: Expected Sub, Function, or Property
    By Cloudfall in forum Excel General
    Replies: 3
    Last Post: 08-30-2005, 01:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1