make a VBA to export pivot chart to word

  • Thread starter make a VBA to export pivot chart to word
  • Start date
M

make a VBA to export pivot chart to word

how do i export a pivot chart to word as a gif or like a clip art/image as i
want to ionsert it into a report
 
W

William

Try this...


Sub test()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
ChDrive "C"
ChDir "C:\MyFolder"
With ThisWorkbook.Sheets("MyChart")
If .HasPivotFields = True Then .HasPivotFields = False
..Export "mychart.gif", "GIF"
End With
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
wrdDoc.PageSetup.Orientation = wdOrientLandscape
wrdDoc.Shapes.AddPicture Filename:="C:\MyFolder\mychart.gif"
Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub

--


XL2003
Regards

William
(e-mail address removed)


"make a VBA to export pivot chart to word"
 
M

make a VBA to export pivot chart to word

Thanks for the prompt response...i guess i have the wrong title..is the
anyway i could do this without having to write a VBA? and if no then the VBA
that you wrote for me where would i insert that...the chart i have is from a
form when change to pivot view so what "event" would i insert the VBA code
into after clicking on the code builder
 
W

William

I assumed from reading your post that you have Excel open and you wanted a
procedure within Excel to copy a chart from the Excel workbook in which the
chart is located to a Word document.

I do not honestly know whether what you want to achieve can be done outside
of VBA - I'd guess it can be done but I don't know how.

The event you would use depends upon the circumstances when you want the
code to run, but you need to be more specific about the form upon which the
chart is located and how the form functions.
--


XL2003
Regards

William
(e-mail address removed)


"make a VBA to export pivot chart to word"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top