Calling Cindy Meister, Jean-Guy Marcil

N

North Wales

Hi Cindy Meister, Jean-Guy Marcil,

I have started this new as I have already marked the other as answered and
was not sure if you would go back to it. Message is a far way back.

I have managed to get the line graph working but stuck on where it gets
inserted. I have replaced the line

Set rngInsertGraph = docCurrent.Content.Paragraphs(2).Range

With

Set rngInsertGraph = Selection.Range

But it goes through the motion but does not appear.

Previous thread is at

http://www.microsoft.com/communitie...6769&tid=ef38442e-030c-431c-8c43-b38b799e1ac0
 
J

Jean-Guy Marcil

North Wales said:
Hi Cindy Meister, Jean-Guy Marcil,

I have started this new as I have already marked the other as answered and
was not sure if you would go back to it. Message is a far way back.

I have managed to get the line graph working but stuck on where it gets
inserted. I have replaced the line

Set rngInsertGraph = docCurrent.Content.Paragraphs(2).Range

With

Set rngInsertGraph = Selection.Range

But it goes through the motion but does not appear.

What is the actual selection in the document when you call the macro?

If the selection is extended (i.e. more than an insertion point), have you
added as I suggestd in the other thread:

rngInsertGraph.Collapse wdCollapseStart
or
rngInsertGraph.Collapse wdCollapseEnd

immediately after the "Set rngInsertGraph = Selection.Range" statement?
 
N

North Wales

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.
 
J

Jean-Guy Marcil

North Wales said:
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.
 
N

North Wales

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
 
Top