Forum Discussion

nastester's avatar
nastester
Regular Contributor
2 years ago
Solved

Setting Excel filename as project variable

Is there a way to set an Excel filename as a variable or something so if it changes name/location I can just update it once in one place?

 

I have a bunch of 'Excel- Read Value" operations in my keyword tests that point to an excel workbook on a network drive.  

They all point to different cells within that workbook but have the same file name. 

 

If the filename changes or moves, I would have to update each operation in every test instead of just updating one time.

Is this possible? 

  • Marsha_R's avatar
    Marsha_R
    2 years ago

    Try it without the quotes around it in the variable value. You might not need those.

6 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Sure! Make it as a string variable

     

    myexcelvariable = "c:\myexceldirectory\myexcelworkbook.xls"

     

    then choose that variable any place you need the file name

     

    If you need to combine it with another string, you would use it in a code expression similar to this

     

     

     

     

     

    • nastester's avatar
      nastester
      Regular Contributor

      Hi Marsha,

      When trying that, I am getting an exception saying file is not found.

      See screenshots.

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3

        If you hard code that same path into the test, does it work?