LHSP‡ 7example <1to10> by <1to10> by <1to10> 1to101to101to10dimensionsymbol!second example of 3D measurementstestÿ|Sub Main SendKeys ListVar1 ' Step 1 – display the first number ' Step 2 - Display unit of measure SendKeys Mid(ListVar4, 1, InStr(ListVar4, "\")-1) SendKeys " x " ' Steps 3 and 6, send the "by" symbol SendKeys ListVar2 ' Step 4 – display the second number ' Step 5 - Display unit of measure SendKeys Mid(ListVar4, 1, InStr(ListVar4, "\")-1) SendKeys " x " ' Steps 3 and 6, send the "by" symbol SendKeys ListVar3 ' Step 7 – display the third number ' Step 8 - Display unit of measure SendKeys Mid(ListVar4, 1, InStr(ListVar4, "\")-1) SendKeys " " ' Step 9 - Display a trailing space End Sub example save for signaturereplacing invalid characterstestýðÿESub Main SendKeys "^{Home}" ' 1. ctrl+home move to top of document SendKeys "%e" ' 2. alt+e select Edit menu MenuPick "Find" ' 3. select the “find” ' Advanced users – the Steps 2 & 3 can be done via a SendKeys "^f" Wait .5 ' 4. Wait a while ' 5. try to find "RE:" then destroy the "Find" window SendKeys "RE:{Enter}{Esc}" Wait .5 ' 6. Wait a while ' 7. move right two then copy the rest of the line SendKeys "{Right 2}+{End}^c" Wait .5 ' 8. alt+f for File, then a for Save As SendKeys "%fa" ' 8. alt+f for File, then a for Save As Wait .5 SendKeys "C:\My Documents\ReadyForSignature\" ' Alternate of SendKeys "C:\Temp\" Wait .5 '----------- Show Replace function ----------- Fname$ = Clipboard ' put clipboard contents into ' the string Fname$ ' replace periods with underline Fname$ = Replace (Fname$, ".", "_") ' replace slashes with underline Fname$ = Replace (Fname$, "/", "_") ' modify step 10 SendKeys Fname$ ' 10. updated file name ' -------- end of String Operations Changes ----- Wait .5 HeardWord "click", "Save" ' 11. save the file End Sub 0sample <1to10> by <1to10> by <1to10> 1to101to101to10 dimension(first example of 3-D measurement commandtestÿ}Sub Main SendKeys ListVar1 ' Step 1 – display the first number ' Step 2 - Display unit of measure If ListVar4 = "inches" Then SendKeys "in." If ListVar4 = "feet" Then SendKeys "'" If ListVar4 = "millimeters" Then SendKeys "mm" If ListVar4 = "centimeters" Then SendKeys "cm" If ListVar4 = "meters" Then SendKeys "m" SendKeys " x " ' Steps 3 and 6, send the "by" symbol SendKeys ListVar2 ' Step 4 – display the second number ' Step 5 - Display unit of measure If ListVar4 = "inches" Then SendKeys "in." If ListVar4 = "feet" Then SendKeys "'" If ListVar4 = "millimeters" Then SendKeys "mm" If ListVar4 = "centimeters" Then SendKeys "cm" If ListVar4 = "meters" Then SendKeys "m" SendKeys " x " ' Steps 3 and 6, send the "by" symbol SendKeys ListVar3 ' Step 7 – display the third number ' Step 8 - Display unit of measure If ListVar4 = "inches" Then SendKeys "in." If ListVar4 = "feet" Then SendKeys "'" If ListVar4 = "millimeters" Then SendKeys "mm" If ListVar4 = "centimeters" Then SendKeys "cm" If ListVar4 = "meters" Then SendKeys "m" SendKeys " " ' Step 9 - Display a trailing space End Sub sample choose formatdialog command for formattingtestÿ‘Sub Main Begin Dialog UserDialog 400,203 ' %GRID:10,7,1,1 TextBox 30,14,330,63,.TextBox1,1 OptionGroup .Group1 OptionButton 40,91,90,14,"bold",.OptionButton1 OptionButton 40,119,90,14,"underline",.OptionButton2 OptionButton 40,147,90,14,"italics",.OptionButton3 OKButton 80,175,90,21 CancelButton 230,175,90,21 End Dialog Dim dlg As UserDialog If Dialog(dlg) = -1 Then Select Case dlg.Group1 Case 0 ' bold s="^b" Case 1 ' underline s="^u" Case 2 ' italics s="^i" End Select ' Wait .5 ' let focus return SendKeys s SendKeys dlg.TextBox1 SendKeys s Else End If End Sub sample control panel applet shell commandtestÿ¨Sub Main ' There are many of these applets. ' Some have different values in different versions of Windows. ' This sample is based on Windows-XP Professional ' The second argument to the Shell command, "vbMaximizedFocus", causes ' windows to open. If not present, then some of these Control ' Panel applets open minimized. Shell("control " & Mid(ListVar1,1,InStr(ListVar1,"\")-1),vbMaximizedFocus) End Sub !sample control panel screen saveropen the screen saver applettest0Sub Main Shell "control desk.cpl,,1" End Sub sample current mouse position+get the current mouse position in clipboardtestýðÿ!Option Explicit Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Type POINTAPI x As Long y As Long End Type ' declare Win32 API functions Declare Function GetCursorPos Lib "user32" _ Alias "GetCursorPos" (lpPoint As POINTAPI) As Long Declare Function GetWindowRect Lib "user32" _ Alias "GetWindowRect" (ByVal hwnd As Long, _ lpRect As RECT) As Long Declare Function GetForegroundWindow& Lib "user32" () Function GetWinCurPos(hwnd As Long) As POINTAPI Dim pt As POINTAPI Dim wRect As RECT Dim result As POINTAPI GetCursorPos pt GetWindowRect hwnd, wRect result.x = pt.x - wRect.Left result.y = pt.y - wRect.Top GetWinCurPos = result End Function Sub Main Dim hwnd As Long Dim result As POINTAPI Dim clip As String hwnd = GetForegroundWindow result = GetWinCurPos(hwnd) clip = "SetMousePosition 5," & result.x & _ "," & result.y clip = clip & Chr(13) & Chr(10) & _ "ButtonClick" & Chr(13) & Chr(10) ' Clipboard clip ' MsgBox clip, 64, "Mouse Test" End Sub sample email subjectsshow subject lines of emailtestÿJSub Main Dim myOlApp As Object Dim intMsgCount As Integer, intMyFoldersCount As Integer Dim myFolder As Variant Dim myNameSpace As Object Dim x As Integer Set myOlApp = CreateObject("Outlook.Application") Set myNameSpace = myOlApp.GetNamespace("MAPI") Set myFolder= myNameSpace.GetDefaultFolder(6) ' intMsgCount = myFolder.Items.Count ' Loop through each message and display the ' unread messages with MsgBox For x = 1 To intMsgCount myUnread = myFolder.Items(x).UnRead If myUnread = True Then MsgBox myFolder.Items(x) End If Next x End Sub sample mole removal risks&document risks of mole removal surgerytestýð Fthere is a risk of infection if the wound is not properly cared for...sample mole removal surgery'mole surgery the Advanced Scripting waytestýðxSub Main SendKeys "The mole was excised to a depth of " SendKeys "2mm " SendKeys "below the skin surface." End Sub "sample mole removal surgery <1to5>1to5a list command illustrationtestýð‚Sub Main SendKeys "The mole was excised to a depth of " SendKeys ListVar1 & "mm " SendKeys "below the skin surface." End Sub sample mole risk insert!another example of text insertiontestýðã{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\cf1\f0\fs24 there is a risk of infection if the wound is not properly cared for... }Fthere is a risk of infection if the wound is not properly cared for...sample open sales taxcalculate sales tax of 8.1%testC:\WINDOWS\Calc.exe C:\WINDOWS\È 0.0818sample phone number  phonelistdisplay phone numbertestDSub Main MsgBox Mid(ListVar1, 1, InStr(ListVar1, "\")-1) End Sub sample save for signature!save a file based on RE: contentstestýðÿOSub Main ' macro to get me home 10 minutes earlier each day SendKeys "^{Home}" ' 1. ctrl+home move to top of document SendKeys "%e" ' 2. alt+e select Edit menu MenuPick "Find" ' 3. select the “find” ' Alternate–Steps 2 & 3 can be done via a SendKeys "^f" Wait .5 ' 4. Wait a while ' 5. try to find "RE:" then destroy the "Find" window SendKeys "RE:{Enter}{Esc}" ' 6. move right two then select the rest of the line ' 7. copy the selected text with ctrl+c SendKeys "{Right 2}+{End}^c" Wait .5 ' 8. alt+f for File, then a for Save As SendKeys "%fa" ' 8. alt+f for File, then a for Save As Wait .5 ' 9. Enter the directory path SendKeys "C:\My Documents\ReadyForSignature\" ' Alternate of SendKeys "C:\Temp\" Wait .5 SendKeys "^v" ' 10. paste the file name Wait .5 HeardWord "click", "Save" ' 11. save the file End Sub sample show window titledisplay title of current windowtestýðÿ ' declare three Windows functions Declare Function GetForegroundWindow& Lib "user32" () Declare Function GetWindowTextLengthA& Lib "user32" _ (ByVal hwnd&) Declare Sub GetWindowTextA Lib "user32" _ (ByVal hwnd&, ByVal lpsz$, ByVal cbMax&) ' ' use Windows functions to obtain a string with the ' title of the current window. The string is returned ' as the value of the ActiveWindowTitle function. Function ActiveWindowTitle$() ActiveWindow = GetForegroundWindow() TitleLen = GetWindowTextLengthA(ActiveWindow) Title$ = Space$(TitleLen) GetWindowTextA ActiveWindow,Title$,TitleLen+1 ActiveWindowTitle$ = Title$ End Function ' Use the window title – in this case, display it. ' More commonly it would be compared. Sub Main MsgBox ActiveWindowTitle$ End Sub sample two boxes-sample using Dialog Editor for two text boxestestýðÿSub Main Begin Dialog UserDialog 400,203,"Two Text Boxes",.dialogfunc ' %GRID:10,7,1,1 Text 10,7,90,14,"Short Text",.Text1 TextBox 120,7,260,21,.TextBox1 Text 20,49,90,14,"Long Text",.Text2 TextBox 130,49,250,84,.TextBox2,1 OKButton 130,161,90,21 End Dialog Dim dlg As UserDialog Dialog dlg SendKeys dlg.TextBox1 SendKeys "~~~" ' tilde "~" is equivalent to "{Enter}" Clipboard dlg.TextBox2 ' TextBox2 text to clipboard SendKeys "^v" ' ctrl+v is to paste the text End Sub Rem See DialogFunc help topic for more information. Private Function dialogfunc(DlgItem$, Action%, SuppValue&) As Boolean Select Case Action% Case 1 ' Dialog box initialization Case 2 ' Value changing or button pressed Rem dialogfunc = True ' Prevent button press from closing the dialog box Case 3 ' TextBox or ComboBox text changed Case 4 ' Focus changed Case 5 ' Idle Rem Wait .1 : dialogfunc = True ' Continue getting idle actions DlgFocus("TextBox1") Case 6 ' Function key End Select End Function sample what time is it give timetestýðrSub Main MsgBox Format(Now, "dddd, mmmm d yyyy") & vbCr & _ Format(Now, "hh:mm:ss AM/PM") End Sub sample yesterdayprint the date of yesterdaytestôSub Main Dim Yesterday As Date Yesterday = Now-1 ' We want only one value for "yesterday" SendKeys WeekdayName(Weekday(Yesterday)) & " " SendKeys MonthName(Month(Yesterday)) & " " SendKeys Day(Yesterday) & " " & Year(Yesterday) End Sub +sample document name_of_document_templateopen a Word templatetestWINWORDMicrosoft Word for WindowsMicrosoft CorporationÿD'#Reference {00020905-0000-0000-C000-000000000046}#8.1#0#c:\Program Files\Microsoft Office\Office\MSWORD9.OLB#Microsoft Word 9.0 Object Library Sub Main ' ' Start with the default User Template directory for Word Filename$ = Options.DefaultFilePath(wdUserTemplatesPath) ' ' append the "\", the file name, and the ".dot" suffix Filename$ = Filename$ & "\" & ListVar1 & ".dot" ' ' prepare for the case where the template does not exist On Error GoTo NoTemplate ' ' open a new instance of the template using the Word ' VBA statement for opening a document template. ' Note the continuation of the statement (“_”) Documents.Add Template:=Filename$, NewTemplate:=False, _ DocumentType:=0 Exit Sub ' NoTemplate: ' Come here if no template exists ErrMess$ = "Template not found: " & ListVar1 MsgBox ErrMess$ End Sub sample insert  insertableinsert a block of texttestWINWORDMicrosoft Word for WindowsMicrosoft Corporationÿ$'#Reference {00020905-0000-0000-C000-000000000046}#8.1#0#c:\Program Files\Microsoft Office\Office\MSWORD9.OLB#Microsoft Word 9.0 Object Library Sub Main ' Create the filename. ' Start with the default file path from Word. If you wish a ' different folder for these files, replace the following ' statement with one of the form ' Filename$ = "your folder name" Filename$ = Options.DefaultFilePath(wdDocumentsPath) ' ' Append a trailing backslash, then the insertable file name, ' then ".doc" to complete the file name. Filename$ = Filename$ & "\" & ListVar1 & ".doc" ' ' The following three lines are from VBA and ' do the file insertion. Selection.InsertFile FileName:= Filename$, Range:="", _ ConfirmConversions:=False, Link:=False, _ Attachment:=False End Sub sample macro oneexecutes Word "macro1" macrotestWINWORDMicrosoft Word for WindowsMicrosoft CorporationÄ'#Reference {00020905-0000-0000-C000-000000000046}#8.1#0#c:\Program Files\Microsoft Office\Office\MSWORD9.OLB#Microsoft Word 9.0 Object Library Sub Main Word.Application.Run "macro1" End Sub 1to10 123456789101to512345appletaccess.cpl\accessibilityappwiz.cpl\add remove programs fonts\fontsmmsys.cpl,,1\multimedia soundsmmsys.cpl,,2\multimedia audio mmsys.cpl,,4\multimedia hardwareprinters\printerstimedate.cpl\date time insertable UnderweightBugsTastedimensionsymbol'\feetcm\centimetersm\metersmm\millimeters in.\inches dimensioninchesfeet millimeters centimetersmeters phonelist(654)765-4321\Joe the neighbor01-999-5432-54321-32\E.T.652-432-4321\company president876-5432\office 987-6543\homename_of_document_templatepay off customer follow upletter