PDA

View Full Version : Pasting charts in the same document - avoiding new instance creation



Frimousse
10-21-2009, 07:54 AM
Hi,

I am having a problem and I don't even know where to begin with that project. I have a sheet in with I have a chart. A VBA program sets an instance of word and then copy this chart at a specific bookmark inside a word template. Then the chart changes (I mean when the chart is copied and pasted, new data comes in - I do what I need to do and copy and paste again). What I need is a way to send this to the same sheet as the previous one (to a different bookmark). As you might be aware, when you open a template, a copy of the document is open (with a different name). At the moment, everything works as planned but the program keeps opening new documents for each new chart. I assume I have to look if an instance exist before I create or open a new one but I am not quite sure where to put it in the code and how to do it generally. Anyone done that before? :banghead:

mdmackillop
10-21-2009, 01:14 PM
You could use the Dir command to look for a file name. If found, open the file and insert the chart. If not found, create a new document from the template.

Frimousse
10-21-2009, 01:19 PM
I am sorry but for this one I am totally clueless as how it would like.
Can you give me an idea of how the "if" line would look like?
Thanks for yout input

mdmackillop
10-21-2009, 01:22 PM
Can you post the code you have?