Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

How do I edit an existing graph datasheet in word using VBA?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JAG777 - 22 Mar 2006 17:20 GMT
I have a .dot file with a number of microsoft graph chart (originally created
from Word tables) objects.
I want to be able to update the datasheet (and tables) of each of the graphs
from the user input captured in text boxes of a user form.
I am struggling with being able to identify the individual chart and then
update its individual data sheet - is this possible?
Jean-Guy Marcil - 24 Mar 2006 18:02 GMT
JAG777 was telling us:
JAG777 nous racontait que :

> I have a .dot file with a number of microsoft graph chart (originally
> created from Word tables) objects.
> I want to be able to update the datasheet (and tables) of each of the
> graphs from the user input captured in text boxes of a user form.
> I am struggling with being able to identify the individual chart and
> then update its individual data sheet - is this possible?

You need to set a reference to "Microsoft Graph 11.0 Object Library" in
Tools > References (VBA Editor menu bar).

Declare some variables like:

   Dim o_OLE As Word.OLEFormat
   Dim diag As Graph.Chart

Then, set the variables, like:

   Set o_OLE = ActiveDocument.Shapes(1).OLEFormat
   o_OLE.DoVerb wdOLEVerbShow
   Set diag = o_OLE.Object

If it is an inlineshape use
   Set o_OLE = ActiveDocument.Shapes(1).OLEFormat

Finally manipulate the object like this:

   With diag.Application.DataSheet
       .cells
       .columns
       .rows
   End With

or

   With diag
       .HasLegend = False
       .Application.PlotBy = xlColumns
       .Width = CentimetersToPoints(25)
       .PlotArea.Width = CentimetersToPoints(20)
       .Axes(xlCategory, xlPrimary).TickLabelSpacing = 1
       .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 90
   End With

And do not forget to destroy the objects:

   'Deactivate the graph object
   diag.Application.Quit

   'Clear objects
   Set diag = Nothing
   Set o_OLE = Nothing

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.