VBA Code, Excel to .pdf, Drop Down List

smithp

New Member
Joined
Mar 16, 2011
Messages
6
Dear All,

Any help would be greatly appreciated, I have the attached VBA code which has been written in Excel 2007. The code basically calls a drop down list in the specified location, creates a postscript file (.ps) then generates a .pdf file, from here it then moves to the next item in the drop down list and repeates the process.

Problem I have encountered is that it all works except the code is weirdly generating every other item in the drop down list, it moves through the list ok and starts the .ps file ok but only outputs every other .pdf - have no idea how to rectify?

Code:
Sub ChangeMASelection()
    Dim Rng As Range
    Dim c As Range
    Dim InputPSFileName As String
    Dim OutPutPDFFileName As String
    Dim sJobOptions As String
    Dim appDist As cACroDist
    Dim StrAgent, StrPath As String
'   Change reference to cell containing vaidation to suit
    With Range("DropDownList")
        Set Rng = Range(Mid(.Validation.Formula1, 2, 255))
        For Each c In Rng
            .Value = c.Value
    StrAgent = Range("DropDownList")     'get the managing agent name
    StrPath = ThisWorkbook.Path
                
            Set appDist = New cACroDist
            Sheets("Charts").Select
            InputPSFileName = "[URL="file://lnscntfs02/fpddata/Claims/Analysis"]\\lnscntfs02\fpddata\Claims\Analysis[/URL] Services Regular Report Production Files\ECF\ECF_Dashboard_Final.ps"
            OutPutPDFFileName = StrPath & "\" & StrAgent & "_ECF Dashboard Report.pdf"
            'OutPutPDFFileName = "[URL="file://lnscntfs02/fpddata/Claims/Analysis"]\\lnscntfs02\fpddata\Claims\Analysis[/URL] Services Regular Report Outputs\ECF_CTP Dashboards\2011 ECF\2011 02\ECF Dashboards\" & StrAgent & "_ECF Dashboard Report.pdf"
            Application.ActivePrinter = "Adobe PDF on Ne02:"
'   Create postscript file
            ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
            "Adobe PDF on Ne02:", PrintToFile:=True, Collate:=True, PrToFileName:="[URL="file://lnscntfs02/fpddata/Claims/Analysis"]\\lnscntfs02\fpddata\Claims\Analysis[/URL] Services Regular Report Production Files\ECF\ECF_Dashboard_Final.ps"
            'Application.Wait Now + TimeValue("00:00:55")
'   Create .pdf file
            Call appDist.odist.FileToPDF(InputPSFileName, OutPutPDFFileName, sJobOptions)
            On Error Resume Next
'            Application.Wait Now + TimeValue("00:00:05")
            Kill InputPSFileName
           
        Next c
    End With
End Sub

Thanks in advance....
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top