Use ASAP Utilities in your own macro
Excel doesn't record the actions you do with add-ins, such as ASAP Utilities when you use the macro recorder. However you can use the following code to start some of the tools in ASAP Utilities.
Important notice
You do have to know the basic understandings of macros/vba to use the macro displayed in the example below. We do not officially support running ASAP Utilities macros from within your own macros and offer help on this.
Example macro
Make sure you have at least ASAP Utilities 4.0 installed on the computer that runs the macro
Starting from version 7.5, in the universal "32+64-bit edition", the file name is "ASAP Utilities.xlam":
Sub sbRunASAPUtilitiesTools_Universal_32and64bit() ' Example on how to start some of the tools ' in ASAP Utilities ' Basic use, command with ID for each utility ' Application.Run "'ASAP Utilities.xlam'!ASAPRunProc", [ID]
' Select » Expand selection to last used row Application.Run "'ASAP Utilities.xlam'!ASAPRunProc", 11
' Columns / Rows » Remove all empty rows Application.Run "'ASAP Utilities.xlam'!ASAPRunProc", 232
' Text » Advanced character removal/replace... Application.Run "'ASAP Utilities.xlam'!ASAPRunProc", 90
' Text » Delete leading and trailing spaces Application.Run "'ASAP Utilities.xlam'!ASAPRunProc", 86
' Select » Deselect cells... Application.Run "'ASAP Utilities.xlam'!ASAPRunProc", 4
End Sub
In the 32-bit only edition of ASAP Utilities, the filename is "ASAP Utilities.xla":
Sub sbRunASAPUtilitiesTools_32bit() ' Example on how to start some of the tools ' in ASAP Utilities ' Basic use, command with ID for each utility ' Application.Run "'ASAP Utilities.xla'!ASAPRunProc", [ID]
' Select » Expand selection to last used row Application.Run "'ASAP Utilities.xla'!ASAPRunProc", 11
' Columns / Rows » Remove all empty rows Application.Run "'ASAP Utilities.xla'!ASAPRunProc", 232
' Text » Advanced character removal/replace... Application.Run "'ASAP Utilities.xla'!ASAPRunProc", 90
' Text » Delete leading and trailing spaces Application.Run "'ASAP Utilities.xla'!ASAPRunProc", 86
' Select » Deselect cells... Application.Run "'ASAP Utilities.xla'!ASAPRunProc", 4
End Sub
In the 64-bit edition of ASAP Utilities 7.1-7.4, the filename is "ASAP Utilities x64.xlam":
Sub sbRunASAPUtilitiesTools_64bit() ' Example on how to start some of the tools ' in ASAP Utilities ' Basic use, command with ID for each utility ' Application.Run "'ASAP Utilities x64.xlam'!ASAPRunProc", [ID]
' Select » Expand selection to last used row Application.Run "'ASAP Utilities x64.xlam'!ASAPRunProc", 11
' Columns / Rows » Remove all empty rows Application.Run "'ASAP Utilities x64.xlam'!ASAPRunProc", 232
' Text » Advanced character removal/replace... Application.Run "'ASAP Utilities x64.xlam'!ASAPRunProc", 90
' Text » Delete leading and trailing spaces Application.Run "'ASAP Utilities x64.xlam'!ASAPRunProc", 86
' Select » Deselect cells... Application.Run "'ASAP Utilities x64.xlam'!ASAPRunProc", 4
End Sub
Skip the startup question on some tools
Some tools ask for a confirmation before they actually start.
You can turn this question off in the settings via:
ASAP Utilities » ASAP Utilities Options » Settings, language and contact information...
and then uncheck the option "Ask for confirmation before starting certain utilities (recommended)"
For some tools this will then also no longer show the confirmation message after a tool has ran, such as for example the "Delete number of leading characters" tool
Send keystrokes
You can use SendKeys to automate the keystrokes you would normally perform. Notice that SendKeys seems to work better then Application.SendKeys in Windows 7 and later.
However, we don't recommend to use sendkeys if you develop a macro that is used by other people too. The Windows sendkeys method doesn't seem to be always 100% reliable. Furthermore, in a newer version of ASAP Utilities certains buttons might change. Still, using SendKeys in combination with ASAP Utilities might save you a lot of extra time/manual labour.
Starting from version 7.5, in the universal "32+64-bit edition", the file name is "ASAP Utilities.xlam":
Sub ExampleWithSendKeys_Universal_32and64bit() ' Sample to automate ASAP Utilities (7.5 and later) ' With the current selected range: ' 1 Delete leading and trailing spaces (86) Application.Run "'ASAP Utilities.xlam'!ASAPRunProc", 86
' 2 Convert to UPPERcase (81) Application.Run "'ASAP Utilities.xlam'!ASAPRunProc", 81
' 3 Insert before and/or after each cell in your selection... (79) ' By using the SendKeys method we can specify the input for the utility upfront: SendKeys "+{HOME}" ' select all text in the insert before field SendKeys "{DEL}" ' make insert before field empty SendKeys "{tab}" ' activate insert after field SendKeys " 2011" ' the text to insert after each cell SendKeys "%o" ' press the OK button ' start the utility: Application.Run "'ASAP Utilities.xlam'!ASAPRunProc", 79
End Sub
In the 32-bit only edition of ASAP Utilities, the file name is "ASAP Utilities.xla":
Sub ExampleWithSendKeys_32bit() ' Sample to automate ASAP Utilities (4.x, 5.x and 7.x 32-bit) ' With the current selected range: ' 1 Delete leading and trailing spaces (86) Application.Run "'ASAP Utilities.xla'!ASAPRunProc", 86
' 2 Convert to UPPERcase (81) Application.Run "'ASAP Utilities.xla'!ASAPRunProc", 81
' 3 Insert before and/or after each cell in your selection... (79) ' By using the SendKeys method we can specify the input for the utility upfront: SendKeys "+{HOME}" ' select all text in the insert before field SendKeys "{DEL}" ' make insert before field empty SendKeys "{tab}" ' activate insert after field SendKeys " 2011" ' the text to insert after each cell SendKeys "%o" ' press the OK button ' start the utility: Application.Run "'ASAP Utilities.xla'!ASAPRunProc", 79
End Sub
In the 64-bit edition of ASAP Utilities 7.1-7.4, the file name is "ASAP Utilities x64.xlam":
Sub ExampleWithSendKeys_64bit() ' Sample to automate ASAP Utilities (7.1-7.4 64-bit) ' With the current selected range: ' 1 Delete leading and trailing spaces (86) Application.Run "'ASAP Utilities x64.xlam'!ASAPRunProc", 86
' 2 Convert to UPPERcase (81) Application.Run "'ASAP Utilities x64.xlam'!ASAPRunProc", 81
' 3 Insert before and/or after each cell in your selection... (79) ' By using the SendKeys method we can specify the input for the utility upfront: SendKeys "+{HOME}" ' select all text in the insert before field SendKeys "{DEL}" ' make insert before field empty SendKeys "{tab}" ' activate insert after field SendKeys " 2011" ' the text to insert after each cell SendKeys "%o" ' press the OK button ' start the utility: Application.Run "'ASAP Utilities x64.xlam'!ASAPRunProc", 79
End Sub
List of all utilities and their IDs
The ID number which you can use to start the utility is displayed in bold between brackets ().
|