Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA help with report bursting

Status
Not open for further replies.

MSIsam

Programmer
Sep 29, 2003
173
US
I have created reports that are bursted to PDF files. The bursting is done by creating a filter on Region, applying the filter for each value, and saving to PDF. This is done for 2 reports in a single document Running the VB code via BCA has given us unspecified error that are periodic. The VB code is not very robust as we do not have a lot of VB experience in our shop and would like some error handling inserted. Any advice on this or performance modifications? Here is the code:

Code:
Sub Macro_ONSC_WEEK_RGN()
   Dim mydoc As Document
    Dim myrpt As Report
    Dim myrpt2 As Report
    Dim myFilterVar As DocumentVariable
    Dim myFilterVar2 As DocumentVariable
    Dim intNumChoices As Integer
    Dim intNumChoices2 As Integer
    Dim i As Integer
    Dim myFilterChoices As Variant
    Dim myFilterChoices2 As Variant
    Dim strNextValue As String
    Dim strNextValue2 As String
    
    Application.Interactive = False
    Application.BreakOnVBAError = False
    Set mydoc = Application.Documents(1)
    Set myrpt = mydoc.Reports.Item(1)
    Set myrpt2 = mydoc.Reports.Item(2)
    Set myFilterVar = mydoc.DocumentVariables("Fin Region ID(SC)")
    Set myFilterVar2 = mydoc.DocumentVariables("Fin Region ID(CR)")
    
    intNumChoices = UBound(myFilterVar.Values(boUniqueValues))
    intNumChoices2 = UBound(myFilterVar2.Values(boUniqueValues))
    
    myFilterChoices = myFilterVar.Values(boUniqueValues)
    myFilterChoices2 = myFilterVar2.Values(boUniqueValues)
    
    For i = 1 To intNumChoices
        
        strNextValue = myFilterChoices(i)
        strNextValue2 = myFilterChoices2(i)
        myrpt.AddComplexFilter myFilterVar, &quot;=<Fin Region ID(SC)>=&quot; & &quot;&quot;&quot;&quot; & strNextValue & &quot;&quot;&quot;&quot;
        myrpt2.AddComplexFilter myFilterVar2, &quot;=<Fin Region ID(CR)>=&quot; & &quot;&quot;&quot;&quot; & strNextValue2 & &quot;&quot;&quot;&quot;   
        myrpt.ForceCompute
        myrpt2.ForceCompute
        mydoc.ExportAsPDF (&quot;\\server\Reports\RGN&quot; & strNextValue & &quot;.pdf&quot;)
        
    Next i
End Sub
 
Hi, in a similar case I just added some error handling routines, I declared an (pseudocode) on error goto error_handler and there I logged everything to the event viewer with a free component found with Google, but you can simply write the error message to a log file.

Stick to your guns
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top