none
Hanging word.application,Not proceeding anymore-Please help me RRS feed

  • Question

  • Hello All,

    On Error Resume Next

    Set objWord=GetObject(,"Word.Application")

    If objWord isNothingThen

    Set objword=Createobject("Word.Application")

    EndIf



    OnErrorGoTo0

                    objword.Documents.Open"C:\Test.Docx"
                    objword.ActiveDocument.Activate

                    objWord.Selection.TypeText "Hello World-Testing happening here buddy"

                    objWord.ActiveDocument.save

                    objWord.ActiveDocument.Close

                    objWord.Quit

    Set objWord=Nothing

    Scenario 1:

    No Word instances in my task manager,i dint open my document and ran this code-It just add the value i meantioned and save succesfully

    Secanrio 2:

    I Open my Document and run this code and it hangs-I am running it through UFT-Automation tool.

    Kindly Help

    Thanks,

    Narayan

    Friday, April 10, 2015 6:34 AM

Answers

  • Hello Narayan,

    >  objword.Documents.Open"C:\Test.Docx"

    The C: drive requires admin privileges for writing in latest OS. Try to choose another drive/folder.

    > I Open my Document and run this code and it hangs-I am running it through UFT-Automation tool.

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. See Considerations for server-side Automation of Office for more information.

    Friday, April 10, 2015 5:21 PM