locked
How to handle the word document which is already opened(Add content to it) using VbScript using "Word.Application" method RRS feed

  • Question

  • Hello,

    I want to add some content to the word document which is opened already and active using vbscript.

    Here is the sample code to have an idea.Kindly Help.

    • Set oWord = CreateObject("Word.Application")
    • oWord.Documents.Open "c:\test.docx" ----->Here i dont want to open the Document as such as my document which is opened already,i have get the control over that document-I try to achive this by using HP UFT tool for word document automation
    • oWord.Selection.EndKey 6,0
    • oWord.Selection.TypeText " This text has been entered by opening the exisitng document. "
    • oWord.ActiveDocument.Save
    • oWord.Quit
    • Set oWord = Nothing
    Thursday, March 19, 2015 10:45 AM

Answers

  • Hi,

    Since you need suggestions about the VBscript, basically this is a development issue, which is better to be discussed in the Word for Developers forum:

    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=worddev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Regards,

    Melon Chen
    TechNet Community Support


    It's recommended to download and install Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office programs. Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Thursday, April 9, 2015 5:53 AM

All replies

  •     Set oWord =   GetObject(  ,  "Word.Application")   
        oWord.Selection.TypeText "You can have it, I promise "
    Monday, March 30, 2015 8:19 AM
  • Hello,

    Nice to see the Reply from you. I have done the same thing what you have suggested but unfortunately i am not achieving the result as expected.

    Here i explain you clearly,

    Business Scenario:

    Using an aplication we will create word documents-To do this we need to fill all the document properties and click on OK button-After this,Application automatically launches a Word Document with the File name given by itself as per the Configuration and it will be available for the Editing-After user add content,he has to check in the document in the application in order to replicate the changes made by user to the document-This is the Business process

    Here my Document actually resides in the Users Folder-"C:\Users\narayanasamy_r\Documentum\Checkout\" before checkin event happened,once i add content,save,close the document,i will navigate to the document in the application  and Do check-in operation.

    Interesting point is that,after i do check-in operation my actual document which was resided in "C:\Users\narayanasamy_r\Documentum\Checkout\" will not be available anymore

    So My logic Should be,

    1.identify that particular Document from the Folder and add content,save and close(Note:i dont want to open the document from "word.application" control here, as the application itself opens up the Document)

    Kindly Help On the same.

    Thanks,

    Narayan

    Tuesday, March 31, 2015 6:59 AM
  • Make your question short and clear.

    If you make it long and complex, you will have no answer at all.

    Regards

    Tuesday, March 31, 2015 8:18 AM
  • Ok understood,kindly Suggest the possible solution here.
    Tuesday, March 31, 2015 8:53 AM
  • Hi,

    Since you need suggestions about the VBscript, basically this is a development issue, which is better to be discussed in the Word for Developers forum:

    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=worddev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Regards,

    Melon Chen
    TechNet Community Support


    It's recommended to download and install Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office programs. Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Thursday, April 9, 2015 5:53 AM