3 Replies Latest reply: Oct 21, 2014 2:10 AM by Uday Kumar RSS

    Export to ppt by looping through all values in listbox

    Uday Kumar
      Hi,
      i have a listbox with different market names. i have chart in my report.
      i am using same chart to refresh for all markets. so i need to export to PPT all these charts at a time.
      it should loop through listbox market values one by one and export those charts to PPT on one button click.
      how we can do?
      i have used one macro, but its not working properly, can anyone check this and tell me what is the problem?
      Sub ExportPPT

      Set PPApp = CreateObject("Powerpoint.Application")

      PPApp.Visible = True

      Set PPPres = PPApp.Presentations.Add
      PPApp.Visible = True

      ActiveDocument.GetApplication.WaitForIdle

      set s=ActiveDocument.Sheets("SH01")
      ActiveDocument.Sheets("SH01").Activate
      ActiveDocument.GetApplication.WaitForIdle

      ActiveDocument.ClearAll False
      Activedocument.Fields("PRODUCT_DIM.MARKET_NAME").Clear
      Set val=ActiveDocument.Fields("PRODUCT_DIM.MARKET_NAME").GetPossibleValues

      PPApp.Visible = True

      For i=val.Count-1 to 0 step -1
      'Activedocument.Fields("measure2.measure2").Clear
      ActiveDocument.Fields("PRODUCT_DIM.MARKET_NAME").Select val.Item(i).Text

      Set PPSlide = PPPres.Slides.ADD(1,11)

      if val.Item(i).Text="Biologic" then

      ActiveDocument.GetSheetObject("CH118").Restore
      ActiveDocument.GetApplication.WaitForIdle
      ActiveDocument.GetSheetObject("CH118").CopyBitmapToClipboard


      elseif val.Item(i).Text="Dermatology" then

      ActiveDocument.GetSheetObject("CH118").Restore
      ActiveDocument.GetApplication.WaitForIdle
      ActiveDocument.GetSheetObject("CH118").CopyBitmapToClipboard


      elseif val.Item(i).Text="Gastroenterology" then

      ActiveDocument.GetSheetObject("CH118").Restore
      ActiveDocument.GetApplication.WaitForIdle
      ActiveDocument.GetSheetObject("CH118").CopyBitmapToClipboard


      elseif val.Item(i).Text="Rheumatology" then

      ActiveDocument.GetSheetObject("CH118").Restore
      ActiveDocument.GetApplication.WaitForIdle
      ActiveDocument.GetSheetObject("CH118").CopyBitmapToClipboard


      elseif val.Item(i).Text="SI Market" then

      ActiveDocument.GetSheetObject("CH118").Restore
      ActiveDocument.GetApplication.WaitForIdle
      ActiveDocument.GetSheetObject("CH118").CopyBitmapToClipboard 
      end if 
      PPSlide.Shapes.Paste             
      ActiveDocument.GetApplication.WaitForIdle
      Next

      set val=nothing

      set PPApp = nothing
      set PPPRes = nothing
      set PPSlide = nothing



      End Sub

      Please help me