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?
Thanks in advance....
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....