Results 1 to 8 of 8

Thread: Capture the objects in a word document

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Feb 2007
    Answers
    3

    Capture the objects in a word document

    Please answer my question.
    Is it possible to capture the objects in a word document for QTP. If so please give me the code.Thanx.


  2. #2
    Expert Member
    Join Date
    Nov 2006
    Answers
    518

    Re: Capture the objects in a word document

    Try applying Learn option on MSWord, it will store all the details of the objects in MSWord in the object repo.

    I recorded some actions in MSWord, here is the code

    Window("Microsoft Word").Activate
    Window("Microsoft Word").WinObject("Menu Bar").Click 24,9
    Window("Microsoft Word").Window("File").Click 23,14
    Window("Microsoft Word").Window("New").WinButton("OK").Click
    Window("Microsoft Word_2").Activate
    Window("Microsoft Word_2").WinObject("_WwG").Type "This is the way to do it."
    Window("Microsoft Word_2").WinObject("Menu Bar").Click 27,14
    Window("Microsoft Word_2").Window("File").Click 46,78
    Window("Microsoft Word_2").Window("Save As").WinObject("way").Type "way"
    Window("Microsoft Word_2").Window("Save As").Click 534,325
    Window("Microsoft Word_3").WinObject("Menu Bar").Click 23,16
    Window("Microsoft Word_3").Window("File").Click 22,48
    Window("Microsoft Word").Activate
    Window("Microsoft Word").WinObject("Menu Bar").Click 21,10
    Window("Microsoft Word").Window("File").Click 35,31
    Window("Microsoft Word").Window("Open").WinObject("OpenListView").Click 23,58
    Window("Microsoft Word").Window("Open").Click 543,321

    Lack of WILL POWER has caused more failure than
    lack of INTELLIGENCE or ABILITY.

    -sutnarcha-

  3. #3
    Contributing Member
    Join Date
    Feb 2007
    Answers
    61

    Re: Capture the objects in a word document

    See if you are using the same code again in another ,this is not going to work coz the Coordinates are not the same again for the statements ".Click .."
    So i have a script to retrienve data from excel..try changing it & retrieve from word
    ex:
    Dim excelobj, count
    count = 1
    Set excelobj = createobject("Excel.Application")
    Set x =excelobj.workbooks.open("C:\default.xls")
    Set y = excelobj.Activeworkbook.worksheets("sheet2")
    While not isempty(excelobj.cells(Count,1))
    d=excelobj.cells(counter,1),value
    msgbox(d)
    count=count+1
    Wend


  4. #4
    Expert Member
    Join Date
    Nov 2006
    Answers
    518

    Re: Capture the objects in a word document

    Yes, I know that the co-ordinated may not match for other users of my code. Its just the sample code that I have shown. The best way is to record ourself.

    Lack of WILL POWER has caused more failure than
    lack of INTELLIGENCE or ABILITY.

    -sutnarcha-

  5. #5
    Contributing Member
    Join Date
    Feb 2007
    Answers
    61

    Re: Capture the objects in a word document

    Also many times qtp wont recognise the same script u have recorded also ..
    So its always better we do it descriptively


  6. #6
    Junior Member
    Join Date
    Feb 2007
    Answers
    3

    Unhappy Re: Capture the objects in a word document

    Hi raghav,

    This is Prasad.You are saying that descriptive programming suitable for word document which is right.Could you please send me the scrippt which is used to identify a object in the file menu.


  7. #7
    Expert Member
    Join Date
    Apr 2007
    Answers
    147

    Re: Capture the objects in a word document

    Hi raghav.kamal
    the code that you have give is for Excel and not Word. Can you please give the code for Word Document


  8. #8
    Junior Member
    Join Date
    May 2008
    Answers
    1

    Re: Capture the objects in a word document

    cAN sOME ONE help me with this....I am trying to do is in my application.Where i will be exporting the data to excel , will save in .xls and has converted it .csv,
    Below is my code

    Set Excelobj = CreateObject("Excel.Application")
    ExcelObj.visible = True
    ExcelObj.Workbooks.open "C:\Documents and Settings\bdevineni\Desktop\"&File_Name&".xls"
    ExcelObj. ActiveWorkbook.SaveAs "C:\Documents and Settings\bdevineni\Desktop\"&File_Name&".csv",6
    set WorkSheetAct = ExcelObj.ActiveSheet
    wait(5)
    ExcelObj.Quit()
    set ExcelObj = Nothing
    next

    I am getting error asking me do u want to save this yes and no ...when i click on yes it is overwritting the existing one,when i am saying no the application is getting closed.Can someone help me where i can say no and close the application here.Modify my code if need.

    Thank U All.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact