Copying an automation object?
-
Hi All, I am new to office automation and I need to perform a simple task. Basically I have to duplicate an Ms word application. What I do is instantiate ms word through a dialog based application using _Application app if(!app.CreateDispatch("word.Application")) { AfxMessageBox("Couldn't start Word and get Application object."); return; } Now I create another instance of word _Application newapp and copy the old instance to the new one. newapp = app; But how do I make the new instance refect the changes? Like show the old word's documents and stuff. Kind of basic question but I have been stuck for hours. Thanks for help Regards, Zahid
-
Hi All, I am new to office automation and I need to perform a simple task. Basically I have to duplicate an Ms word application. What I do is instantiate ms word through a dialog based application using _Application app if(!app.CreateDispatch("word.Application")) { AfxMessageBox("Couldn't start Word and get Application object."); return; } Now I create another instance of word _Application newapp and copy the old instance to the new one. newapp = app; But how do I make the new instance refect the changes? Like show the old word's documents and stuff. Kind of basic question but I have been stuck for hours. Thanks for help Regards, Zahid
You don't. At least, not by doing what you're doing. That's like saying that I've overwritten your email address in my address-book with someone else's address, why aren't you them? You can use automation to enumerate the open documents, and then open them in the second copy, but that's about it. You can force the first instance to save all changes, and then get the second one to reload, but why? What's so special about the first instance of Word you have that means you want another one 'just like it'...? Steve S
-
You don't. At least, not by doing what you're doing. That's like saying that I've overwritten your email address in my address-book with someone else's address, why aren't you them? You can use automation to enumerate the open documents, and then open them in the second copy, but that's about it. You can force the first instance to save all changes, and then get the second one to reload, but why? What's so special about the first instance of Word you have that means you want another one 'just like it'...? Steve S
Thanks for suggestion So I can't do it? Thats depressing since I not only needed the documents but also what buttons like BOLD, ITALIC were pressed or was the word in Print Preview mode or normal mode etc. Actually my actual goal is that I want to transfer the word to another machine with its state intact. I figured that if I could do it on one machine then doing it on multiple would be easy. So there is no other method available other than saving the document in a file and reloading it??? We can't copy the object's attributes and paste them to another object somehow? Thanks. Regards, Zahid
-
Thanks for suggestion So I can't do it? Thats depressing since I not only needed the documents but also what buttons like BOLD, ITALIC were pressed or was the word in Print Preview mode or normal mode etc. Actually my actual goal is that I want to transfer the word to another machine with its state intact. I figured that if I could do it on one machine then doing it on multiple would be easy. So there is no other method available other than saving the document in a file and reloading it??? We can't copy the object's attributes and paste them to another object somehow? Thanks. Regards, Zahid
No you can't. That's a qualified "no". If you're doing it for disaster recovery purposes, then it might well be worth spending the time writing a clone routine that for a given document replicates it's content, cursor position etc to another instance on a separate machine. You could query every property and set them on another instance, but it would take a very long time in two senses. Firstly, this would introduce a noticeable delay to the user (for noticeable, read unacceptable). Secondly, it's going to take a long time to cover all the properties. Steve S