Micro Focus QTP (UFT) Forums

Full Version: Relative Path problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I am trying to use the relative path in qtp to open a excel file to take input from and maintaining a definite folder structure. But on using this function
getabsolutepath in qtp gives C:\Program Files\HP\QuickTest Professional\bin
as my current working directory. How to use my script path as the current working directory, I have tried added the path in Tools->Options->Folder but it sometimes open C:\Program Files\HP\QuickTest Professional\bin as my current working directory.
Thanks
Code:
TestDir=Environment.Value("TestDir")
TestNameLength=Len(Environment.Value("TestName"))
TestDir=Left(TestDir,Len(TestDir)-TestNameLength)
Set excel = CreateObject("Excel.Application")
InitFilePath=TestDir+"\Init\Init.xls"
Set workbook = excel.Workbooks.Open(InitFilePath)
Set worksheet=workbook.Worksheets("Sheet1")
Set url = worksheet.Cells.Find("url")
urladd= worksheet.Cells(url.row,(url.column)+1)
excel.Quit
SystemUtil.Run urladd

my test directory(folder) is "Test" and am having a folder named "Init" beside my test folder. there i am having a excel file "Init.xls" to store url of the application. i read it using the above code. the idea is, i have used the
predefined environment variable "TestDir" for my logic.