Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    compile error (excell 00)

    Hello, I am having trouble running a marco i developed it wont compile.

    I think my code is very insuffcient??

    any suggestions to my attachment??

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: compile error (excell 00)

    Lots of variables haven't been declared.
    The function GetProfileSectionA is not defined in the attachment.
    Apart from that, the code compiles OK (which does not mean it'll do what you want)

  3. #3
    2 Star Lounger
    Join Date
    May 2005
    Location
    Vancouver, Br. Columbia
    Posts
    223
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: compile error (excell 00)

    I was able to go throught the code and shrink it removing some usless stuff but still having the compiling error which highlights
    Sub PrintPDFSurfaceProgram()


    Sub PrintPDFSurfaceProgram()
    ' - checks most sheets for Autofilter turned on and set to NonBlanks (Criteria1="<>"), warns then stops
    ' - selects Program sheets
    ' - prints Program sheets
    ' - unselects Program sheets
    '
    Dim vNames
    Dim x As Integer
    Dim rCell As Range
    Dim vPrintSheets
    vsavecurrentprinter = Application.ActivePrinter
    vPDFPrinter = Worksheet("ProgramChecklist").Range("PDFprinter1")
    vNames = Array("Surface Pricing")
    vPrintSheets = Array("Title Page", _
    "Stage 1 Job Info", "Surface Casing G.P.", "Surface Pricing", "T&C")

    ' check AutoFilter for each sheet
    For x = LBound(vNames) + 1 To UBound(vNames)
    With Worksheets(vNames(x))
    If .AutoFilter Is Nothing Then
    MsgBox "ERROR - Sheet '" & .Name & _
    "' AutoFilter not turned on for column A!" & vbCrLf & vbCrLf & _
    "Either turn it on (Select column A, then Data, Filter, Autofilter, " _
    & "then set it to '(nonBlanks)')" & vbCrLf & vbCritical
    Exit Sub
    ElseIf .AutoFilter.Filters(1).On = False Then
    MsgBox "ERROR - You need to set '" & .Name & _
    "' AutoFilter to '(nonBlanks)'!", vbCritical
    Exit Sub
    ElseIf .AutoFilter.Filters(1).Criteria1 <> "<>" Then
    MsgBox "ERROR - You need to set '" & .Name & _
    "' AutoFilter to '(nonBlanks)'!", vbCritical
    Exit Sub
    End If
    End With
    Next



    ' select all Program sheets

    On Error Resume Next ' turn on error handling
    ' print Program sheets
    Set Application.ActivePrinter = vPDFPrinter
    Sheets(vPrintSheets).PrintOut Copies:=1, Collate:=True

    ' set ProgramLastPrinted cell to now
    If Err.Number = 0 Then Range("ProgramLastPrinted").Value = Now()
    Set Application.ActivePrinter = vsavecurrentprinter
    End Sub


    ??

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: compile error (excell 00)

    You still have lots of undeclared variables.

    It should be

    vPDFPrinter = Worksheets("ProgramChecklist").Range("PDFprinter1")

    (Worksheets, not Worksheet)

    ActivePrinter is a string, not an object, so you should NOT use the word Set (twice):

    Application.ActivePrinter = ...

    (These errors were not present in the original code)

  5. #5
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: compile error (excell 00)

    An additional comment the line:
    <pre>On Error Resume Next ' turn on error handling</pre>


    Does not turn on error handling (it would more accurately be called turning error handling off: "just run and ignore any errors"), it just ignores any error that comes from then on in the code. It should be used sparingly and only for specific lines of code and then put error handling back on:

    <pre>On error goto 0</pre>


    Steve

  6. #6
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: compile error (excell 00)

    Thanks i will make these changes

Posting Permissions

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