powerplay-export.mac 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. Dim objApp As Object
  2. Dim objRep As Object
  3. Dim filename as String
  4. Dim folder as String
  5. Dim publish As String
  6. Dim exportFormat As String
  7. Sub Main ()
  8. Rem On Error Resume Next
  9. Set objApp = CreateObject("CognosPowerPlay.Application")
  10. rem folder = "C:\GAPS\Portal\System\Report"
  11. rem filename = "test.ppr"
  12. rem exportFormat = "pdf"
  13. rem publish = "C:\GAPS\Portal\daten"
  14. folder = GetField(Command, 1, ",")
  15. filename = GetField(Command, 2, ",")
  16. exportFormat = GetField(Command, 3, ",")
  17. publish = GetField(Command, 4, ",")
  18. Dim exportFile as String
  19. Dim objPDF as Object
  20. If LCase(Right(filename, 4)) = ".ppr" Or LCase(Right(filename, 4)) = ".ppx" Then
  21. Set objRep = CreateObject("CognosPowerPlay.Report")
  22. objRep.Open(folder + "\" + filename)
  23. exportFile = publish + "\" + Left(filename, Len(filename) -4)
  24. Select Case exportFormat
  25. Case "pdf"
  26. Set objPDF = objRep.PDFFile(exportFile + "_0.pdf", True)
  27. With objPDF
  28. .SaveEntireReport = True
  29. .AxisOnAllPages = True
  30. .ChartTitleOnAllPages = False
  31. .IncludeLegend = False
  32. End With
  33. objPDF.Save
  34. For i = 1 to objRep.Layers.Count
  35. Set objPDF = objRep.PDFFile(exportFile + "_" + i + ".pdf", True)
  36. With objPDF
  37. .SaveEntireReport = False
  38. .SaveAllCharts = False
  39. .AxisOnAllPages = True
  40. .ChartTitleOnAllPages = False
  41. .IncludeLegend = False
  42. .SetListOfLayersToSave objRep.Layers.Subset(i, i)
  43. .SetListOfRowsToSave objRep.Rows
  44. End With
  45. objPDF.Save
  46. Next
  47. Case "asc"
  48. objRep.SaveAs exportFile, 3
  49. Case "xls"
  50. objRep.SaveAs exportFile, 4
  51. Case "ppx"
  52. objRep.SaveAs exportFile, 5
  53. Case Else
  54. objRep.Publish publish, False, True, True
  55. End Select
  56. objRep.Close
  57. End if
  58. objApp.Quit
  59. End Sub