NorthWales
Mon Jun 16 13:55:00 PDT 2008
Hi Jean,
Its not you who is thick, but me, after all i was the one who asked the
question.
Anyhow thats brilliant everything working, thanks for the help
--
Rich...
http://www.jadwizracing.co.uk
"Jean-Guy Marcil" wrote:
> "North Wales" wrote:
>
> > Hi Jean,
> >
> > At the moment I have just a new blank page and pressed the enter a few times.
> > Just to make sure i have things in the right order. When i run it with the
> > line
> >
> > Set rngInsertGraph = docCurrent.Content.Paragraphs(2).Range
> >
> > it works fine. But if i replace that line with
> >
> > Set rngInsertGraph = Selection.Range
> >
> > and then have either
> >
> > rngInsertGraph.Collapse wdCollapseStart
> > or
> > rngInsertGraph.Collapse wdCollapseEnd
> >
> > on the next line it does not.
> > But it does still place the line of text that you added at the bottom of the
> > code.
> >
>
> Sorry for being so thick... I just looked a the code I posted, but this time
> I did replace the line setting the range... As soon as I had done that, I
> saw the problem right away...
>
> My code works with two documents. Originally, I set the range object using
> the Object document. This was independant of whatever was hapenong on the
> screen. But now you want to use the Selection object. The selection points to
> whatever is active on the screen at the time the code runs. In this case, it
> is the second document, the Data source one. So the chart is being inserted
> in that document, but when the document gets closed it with the code, the
> code does not save the changes, so you never even see it...
>
> So, you have to set the range object before opening the second document...
> Replace the first few lines of the code I provided before with these lines:
>
> 'Then, set the variables, like:
> Set docCurrent = ActiveDocument
> 'Inserting graph at the current selection instead...
> Set rngInsertGraph = Selection.Range
> rngInsertGraph.Collapse wdCollapseStart
>
> Set docSourceData = Application.Documents.Open("C:\My Documents\test.doc")
> Set tblData = docSourceData.Tables(1)
>
> rngInsertGraph.InlineShapes.AddOLEObject ClassType:="MSGraph.Chart.8", _
> FileName:="", LinkToFile:=False, DisplayAsIcon:=False
>
> Sorry again.