Home |
Search |
Today's Posts |
#9
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
The piece of code that actually invokes the EditChart sub is an event
handler in the clsMergeEvents module that does this: If Doc.Bookmarks.Exists(BookmarkName) Then Set rngChart = Doc.Bookmarks(BookmarkName).Range EditChart rngChart, DataDoc So if your code got this far: Set of = rng.InlineShapes(1).OLEFormat then the bookmark does exist. But for that to work a. the bookmark must "cover" at least one InlineShape b. the first such InlineShape would have to be a shape type that has an OLEFormat. A Chart object inserted as per the sample mail merge main document should be set up OK, and indeed anything that is inserted by embedding an object, but it could be that you have inserted the chart in some other way (e.g. as a picture rather than an OLE object, and that may not have a .OLEObject. Or perhaps the object is contained within a Drawing Canvas - I'm not sure whether that would cause this problem). Peter Jamieson http://tips.pjmsn.me.uk On 25/02/2010 21:50, Stephanie J wrote: I too used the VB code, and received an error message at this line: Set of = rng.InlineShapes(1).OLEFormat The error says: "Run-Time error '5941': The requested member of the collection does not exist" When I click "debug" it highlights teh last line listed below. ----- Option Explicit Public x As New Class1 Public BeforeMergeExecuted As Boolean Public CancelMerge As Boolean Public recordIndex As Long Const ChartDataDoc As String = "ChartData.doc" Sub MergeWithChart() 'Preset the global variables BeforeMergeExecuted = False CancelMerge = False recordIndex = 1 'The events in the class module 'Class1 will be enabled ActivateEvents 'As each record is merged 'the MailMergeBeforeMerge 'event will be called ActiveDocument.MailMerge.Execute Pause:=False 'Turn the events off so that they 'only execute for this document DeactivateEvents End Sub Sub ActivateEvents() Set x.WdApp = Word.Application End Sub Sub DeactivateEvents() Set x.WdApp = Nothing End Sub Function OpenChartDataFile(LocalPath As String) _ As Word.Document Dim FilePath As String 'Combine the path where the main merge doc 'is stored plus the specified name of the 'document containing the data for the chart FilePath = LocalPath& "\"& ChartDataDoc 'Make sure the data file exists 'before trying to open it If Dir(FilePath) "" Then Set OpenChartDataFile = Documents.Open( _ FileName:=FilePath, _ ReadOnly:=True, _ AddToRecentFiles:=False, _ Visible:=False) End If End Function Sub EditChart(rng As Word.Range, _ DataDoc As Word.Document) Dim of As Word.OLEFormat Dim oChart As Graph.Chart Dim oDataSheet As Graph.DataSheet Dim tbl As Word.Table Dim chartType As Long Set tbl = DataDoc.Tables(1) 'Activate the MS Graph object in the 'main merge document Set of = rng.InlineShapes(1).OLEFormat Moll wrote: Create Pie Chart Whilst Mail Merging 04-Mar-09 "Doug Robbins - Word MVP" wrote: Previous Posts In This Thread: On Wednesday, February 11, 2009 12:42 PM Storm wrote: Create Pie Chart Whilst Mail Merging Hi, I have an Excel Sheet with 1000 lines of data. Some of the data is text (people's names etc) and some is numbers. I'd like to run a mail merge to Word that pulls some of the data across as it is - such as the names - but also creates a pie chart for each line using the other data. Is this possible? Thanks On Wednesday, February 11, 2009 3:05 PM Peter Jamieson wrote: I'd have a look at the "Merge with Chart"/"Mail Merge to a chart" section on I'd have a look at the "Merge with Chart"/"Mail Merge to a chart" section on Condy Meister's website at http://homepage.hispeed.ch/cindymeister/MergFram.htm Peter Jamieson http://tips.pjmsn.me.uk Stormy wrote: On Thursday, February 19, 2009 1:46 PM IlliniGir wrote: I have tried using the fourth method that Cindy suggests, but I am having I have tried using the fourth method that Cindy suggests, but I am having problems with the VB code, as I am not well-versed in it. I find the instructions hard to follow without VB knowledge. In the basic module it asks for a filepath. I put mine in (H:\My Documents\Benefits\ChartDataDoc) and I get a compile error message that says "Expected: line number or label or statement or end of statement." Can you tell me what I'm doing wrong? "Peter Jamieson" wrote: On Thursday, February 19, 2009 4:49 PM Doug Robbins - Word MVP wrote: It would be easier to help you if you copied and pasted into a message the It would be easier to help you if you copied and pasted into a message the whole routine, indicating which line produces the error message. |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Generic chart to populate when mail merging. | Mailmerge | |||
How do you create a pie chart with mail merge | Mailmerge | |||
how can I create a chart in mail merge? | Mailmerge | |||
How do I create a pie chart in word? | Microsoft Word Help | |||
HELP WITH MERGING CHART DATA | Mailmerge |