Ask a Question

Setting Excel filename as project variable

SOLVED
nsievert
Frequent Contributor

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? 

6 REPLIES 6
Marsha_R
Community Hero

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

 

string.png

 

 

 

 


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
nsievert
Frequent Contributor

Hi Marsha,

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

See screenshots.

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


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
nsievert
Frequent Contributor

Yes it does. When I hardcode a path to a network drive or local drive path, it works.

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


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
nsievert
Frequent Contributor

That was seemingly it! Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: