preload

How to enlist Excel VBA macros (QTP, VBScript)

Posted by Albert Gareev on Jan 20, 2010
1
Parent page: Service Functions – Excel (QTP, VBScript) Answers Description Connect to Excel through COM - Open workbook - Retrieve Code Module object - Retrieve Code Block string - Parse the string – close and save the workbook. Notes. For this example let’s assume our target Workbook is stored as “C:\Temp\1.xls”, and our target Code Module is named “Module1″, and we’re looking for ...

How to exchange parameters with Excel VBA function ...

Posted by Albert Gareev on Jan 15, 2010
0
Parent page: Service Functions – Excel (QTP, VBScript) Answers 1. To pass-in parameters to an Excel VBA function A function must be public and belong to a Macro Module. QTP/VBScript source code Set XLHandle =  CreateObject("Excel.Application") XLHandle.DisplayAlerts = False     Set XLBook = XLHandle.WorkBooks.Open("c:\temp\1.xls") On Error Resume Next Call XLHandle.Run("ArgFunction", 5) boolRC = Err.Number ...

How to call Excel VBA function from QTP

Posted by Albert Gareev on Jan 14, 2010
0
Parent page: Service Functions – Excel (QTP, VBScript) Answers Description Connect to Excel through COM - Open workbook - Invoke the function - Catch error - close and save the workbook. Notes. Macro (Sub or Function) must be public and belong to a Macro Module. Set XLHandle =  CreateObject("Excel.Application") XLHandle.DisplayAlerts = False     Set XLBook = XLHandle.WorkBooks.Open("c:\temp\1.xls") On Error ...

How to update value in XML file (QTP, VBScript)

Posted by Albert Gareev on Dec 30, 2009
0
Parent page: Service Functions – XML (QTP, VBScript)  Answers Description Open XML file – load into memory – locate target nodes – update (replace) values – save XML file (either under a new name or overwrite the original file). Search is performed by tag name (“target_node”). If you pass in a non-string parameter for .SetValue function, convert [...] ...

How to count XML nodes (QTP, VBScript)

Posted by Albert Gareev on Dec 29, 2009
0
Parent page: Service Functions – XML (QTP, VBScript)  Answers 1. How to count all direct children? Set objColl = objParent.ChildElements() intCount = objColl.Count 2. How to count all direct children, specific name tag? Set objColl = objParent.ChildElementsByPath("./wanted") intCount = objColl.Count 3. How to count all descendants? Set objColl = objParent.ChildElementsByPath("descendant::*") intCount = objColl.Count ...

How to use loops in Dexterity Macro

Posted by Albert Gareev on Dec 21, 2009
0
All related posts: Reference Page – GP/QTP Automation  Answer According to the documentation, there are no loop operators defined in Microsoft Dynamics Great Plains Dexterity Macros. However, the macro language provides other commands to workaround the issues in the most required cases. Workarounds 1. Capture values of GUI fields (in a loop) Use DumpFieldBegin…DumpFieldEnd commands. 2. Window synchronization [...] ...

How to create a unique subfolder (QTP, VBScript)

Posted by Albert Gareev on Dec 16, 2009
1
Parent page: Service Functions – System (QTP, VBScript) How to create a unique subfolder Description A subfolder is created based on the name pattern and a date-time stamp, e.g. “AccountSearch 2009-10-14 17-18-03″.  You can add extra steps and form the code as a function that returns full path of the newly created subfolder. sName – name pattern sFullPath [...] ...

How to duplicate an existing file (QTP, VBScript)

Posted by Albert Gareev on Dec 15, 2009
0
Parent page: Service Functions – System (QTP, VBScript) How to duplicate an existing file (If you want to access the file but it’s locked) Description sFileName – name of the file to duplicate sNewName – name of created file (generated automatically), pass-back argument. Uses UniqueFilename function to generate a name for the duplicate file. Public Function DuplicateFile(ByVal [...] ...

How to generate unique file name (QTP, VBScript)

Posted by Albert Gareev on Dec 14, 2009
0
Parent page: Service Functions – System (QTP, VBScript) How to generate a unique file name if the file name already exists in the given folder (That often happens, if you need to create a series of files or duplicate an existing file) Description sFileName – the “original” file name or file name template sFolderName – parent folder [...] ...

Using built-in and system dialogs in QTP

Posted by Albert Gareev on Nov 19, 2009
0
Even though automated testing scripts are intended to communicate with application under test there are cases when communication with tester is required. With QTP, we can use either built-in MsgBox / InputBox functions or link standard Windows dialogs through COM. MsgBox Use this function to report information (like value of a variable) during debugging or [...] ...

How to separate file name and path (QTP, VBScript)

Posted by Albert Gareev on Oct 25, 2009
0
Parent page: Service Functions – System (QTP, VBScript) Use FileSystemObject.GetFile method to obtain a File object. Argument should be a full path string. Set FSO = CreateObject(“Scripting.FileSystemObject”) Check if the file exists first. When to use it? There is a variety of utility tasks related to it: get parent folder, create another file in the same folder, create another [...] ...

How to check if file exists (QTP, VBScript)

Posted by Albert Gareev on Oct 24, 2009
2
Parent page: Service Functions – System (QTP, VBScript) Use FileSystemObject.FileExists method. Argument should be a full path string.   When to use it? Always before trying to access the file (delete, rename, or read from).   Does file format matter? No. It could be text file, excel spreadsheet, bitmap, binary file, – anything. Just make sure you [...] ...

How to open Excel workbook (QTP, VBScript)

Posted by Albert Gareev on Oct 17, 2009
0
Parent page: Service Functions – Excel (QTP, VBScript) Description Check the file exists – Create an instance of Excel by using COM – open (load) file Dim XLHandle, XLBook Public Function OpenWorkbook(ByVal sFileName)  Dim FSO, boolRC  Set FSO = CreateObject("Scripting.FileSystemObject")  boolRC = FSO.FileExists(sFileName)  Set FSO = Nothing  If Not boolRC Then   OpenWorkbook = FALSE   Exit [...] ...

DotNetFactory interface functions – create ...

Posted by Albert Gareev on Jun 18, 2009
2
Parent page: Service Functions – DotNetFactory (QTP, VBScript) Used resources Service Functions – String (QTP, VBScript) Implementing optional and default parameters Create TextBox along with the Prompt Label and place on the GUI Form  Public Function PlaceTextBox(ByRef objForm, ByVal objParameter)     Dim sPrompt     Dim intLeft, intTop     Dim objTextBox, objLabel   'Verify parameters   If TypeName (objParameter) <>  ...

Text File compare in “WDIFF” style (QTP, ...

Posted by Albert Gareev on May 27, 2009
0
Original date: N/A The post has been mostly recompiled from the comments. Displaying Text File comparison results in an embedded report. Refer to Text File Compare functions used to see how XML file is generated. Sample requirements to show comparison results stored in XML as a web-page (HTML). 1. Show file stats saved in xml file. [...] ...

Implementing optional and default parameters (QTP, ...

Posted by Albert Gareev on May 24, 2009
0
Original date: 16 Dec 2008, 1:14pm Service function Public Function AssociateParameters(ByVal strParams)  Dim objDictionary, Values, strPair, Pair  Dim intCount, i    strParams = Replace(strParams, "\,", Chr(176))  strParams = Replace(strParams, "\=", Chr(187))  Values  = Split(strParams, ",")  intCount = UBound(Values)  Set objDictionary = CreateObject("Scripting.Dictionary")  For i=0 To ...

Mapping Excel col names (QTP, VBScript)

Posted by Albert Gareev on May 23, 2009
1
Original date: 5 Dec 2008, 1:23pm Parent page: Service Functions – Excel (QTP, VBScript) 'Assumptions: 'Excel file exists 'Workbook is open (XLBook) 'Sheet exists Set objUsedRange = XLBook.Worksheets(sSheetIndex).UsedRange() Set objSheetColNameMap = CreateObject("Scripting.Dictionary") For Iter = 1 To objUsedRange.Columns.Count sCellText = objUsedRange.Cells(1,Iter) If sCellText <> "" Then ...

Custom lists: Select Multi / Select All with WinRunner

Posted by Albert Gareev on Dec 23, 2007
0
How to select multiple items in custom list Description Select each item with “Control” key (Ctrl on keyboard). public function _list_select_multy(in list, in items) {  auto rc, count, i, k;  auto dvItem[];    count = split(items, dvItem, ",");  if (count < 1) {   return(E_GENERAL_ERROR);      }      rc = list_select_item(list, str_trim(dvItem[1]));  if (rc != E_OK) { [...] ...

WinRunner custom dialogs: parameterize your scripts at ...

Posted by Albert Gareev on Dec 21, 2007
0
How to input parameters for WinRunner scripts Description In order to use a customizable dialog, you need to declare data fields and data handler that will populate them as per your needs/rules. # create_custom_dialog specific fields static _env_str, _case_str, _input_str; # public function _on_param_dlg(in env_str, in case_str, in input_str) {  _env_str = env_str;  _case_str = [...] ...
Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.