Reputation: 71
Could someone help me with logic, i am new to automation UFT.
My aim is to save PDF by changing the name and in specific folder.
I used below logic to save PDF, but it works for only one time, as PDF already saved on desktop. I got around 200 PDF in browser.
Browser("Login").Page("Select Letter").WebButton("Enter").Click
Browser("Login").Page("Select Letter").WebButton("Next").Click
Browser("Login").Page("Select Letter").WebButton("Preview").Click
Browser("Login").Page("Select Letter").Sync
Set WshShell = CreateObject("WScript.Shell")
Browser("Browser").WinObject("AVPageView").highlight
WshShell.SendKeys "+^s"
Browser("Browser").Dialog("Save a Copy").WinTreeView("WinTreeView").Select "Favorites;Desktop"
Browser("Browser").Dialog("Save a Copy").WinButton("Save").Click
Browser("Browser").CloseAllTabs
Thanks in Advance
Sush
Upvotes: 1
Views: 2895
Reputation: 1063
Based on your comment, I would try something like this..
Dim strFolderPath, strFileName, strFullPathToSave
Dim strCurrentTime
' Add the folder path
strFolderPath = "C:\A_Preffered_Folder\PDF"
' Generate FileName
strCurrentTime = now
strFileName = Replace(Replace(Replace(strCurrentTime, "/",""),":",""), " ", "_")
strFullPathToSave = strFolderPath + "\" + strFileName + ".PDF"
NOW is the keyword, which would give you the current date and time. I simply replaced the "/", Spaces & ":" to genrate a file name. Just record saving the file again, this time instead of browsing the file, just type the full path. Ex: C:\A_Preffered_Folder\PDF\132017_35655_PM.PDF But make sure that the folder exists first. Once you have the code add the above code after you press ctrl s and replace the hardcoded value with the variable where you the file name.
Upvotes: 2