Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Copying an automation object?

Copying an automation object?

Scheduled Pinned Locked Moved COM
questionhelptestingtools
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zee man
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • Z Zee man

      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

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      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

      Z 1 Reply Last reply
      0
      • S 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

        Z Offline
        Z Offline
        Zee man
        wrote on last edited by
        #3

        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

        S 1 Reply Last reply
        0
        • Z Zee man

          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

          S Offline
          S Offline
          Steve S
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups