SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Oct 2005
    Location
    Mumbai
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to a delcare Global Variables in an Excel

    Hi,

    I would like to declare the Global Variables in an Excel Sheet instead of a .vbs file,
    In the Excel Sheet Coloumn A, I have mentioned the Variable names, and Column B with Corresponding value

    Eg:
    ___________________
    A B
    ___________________
    loginId Agent
    -------------------
    Pwd Merecury
    --------------------

    and etc


    In my Script the msgbox loginId should Display "Agent"

    --------

    Iam able to pick the Value from Coloumn B and assaign it to Variable in Column A,

    But i could not use that Varibale in my Script, It gives me Blank

    Could you please help me on this?

    Thanks,

    Regards,
    Krishna
    krishna chaitanya.k

  2. #2
    Moderator
    Join Date
    Sep 2001
    Location
    Doncaster, UK
    Posts
    5,839
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to a delcare Global Variables in an Excel

    I would suggest that your retrieval code is not functioning correctly as it is possible to do this from QTP.

    Why not post your code to see if anyone can spot the issue?

    Mark Smith.

  3. #3
    Junior Member
    Join Date
    Oct 2005
    Location
    Mumbai
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to a delcare Global Variables in an Excel

    Hi Mark,

    I have written the below Code for assaigning the Column B values to the Variables mentioned in the Column A,

    A B
    loginId Agent
    Pwd Mercury
    Lang English

    --------------------------------------

    Set xlobj = CreateObject("Excel.Application")
    xlobj.workbooks.open"C:\Temp.xls"
    xlobj.visible=true
    Set newsheet=xlobj.sheets.item(1)
    iRowCount=newsheet.cells.range("A:A").currentregio n.rows.count
    For i=1 to iRowCount
    Var=trim(newsheet.cells((i),("A")).value)
    Val=trim(newsheet.cells((i),("B")).value)
    Var=Val
    msgbox Var
    Next
    -------------------------------

    My requirement is after executing the above for Loop in the Script,

    msgbox loginId ' Should Display Agent
    msgbox Pwd ' Should Display Mercury
    msgbox Lang ' Should Display English

    Could you please let me know, how this can be Achieved?

    Thanks you,

    Regards,
    Krishna
    krishna chaitanya.k

  4. #4
    Advanced Member RKY's Avatar
    Join Date
    Aug 2006
    Location
    Hyderabad, India
    Posts
    586
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to a delcare Global Variables in an Excel


    Use Public keyword to declare in a global way. Outside the function

  5. #5
    Advanced Member
    Join Date
    Aug 2007
    Location
    Six Feet Under
    Posts
    717
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to a delcare Global Variables in an Excel

    though i did not try this yet but i am sure it will never work
    Still there's a Workaround to every problem.

    steps
    a) add another sheet.
    b) write that variable value to 1 cell of column A or "loginId" (Ask if you need some here)
    c) now u can read this using QTP.

    All done!
    Thanks,
    Manish Bansal

    Checkout Blog Page At
    http://www.softtechlabs.com

  6. #6
    Moderator
    Join Date
    Sep 2001
    Location
    Doncaster, UK
    Posts
    5,839
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to a delcare Global Variables in an Excel

    Not sure why you want to do this as it seems like you are overcomplicating things, but this seems to work:


    'Get loginID
    Dim loginID
    ID = "loginID"
    Call RetrieveValue(ID,val)
    LoginID = val
    MsgBox loginID
    Function RetrieveValue(ID,val)

    Set xlobj = CreateObject("Excel.Application")
    xlobj.workbooks.open"C:\Temp\Temp.xls"
    xlobj.visible=true
    Set newsheet=xlobj.sheets.item(1)
    iRowCount=newsheet.cells.range("A:A").currentregio n.rows.count
    For i=1 to iRowCount
    If newsheet.cells((i),("A")).value = ID Then
    val = newsheet.cells((i),("B")).value
    Exit For
    End If
    Next

    End Function


    Mark Smith

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.40 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.7.1 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.3.0 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:11 PM.

Copyright BetaSoft Inc.