C 言語関数呼び出しの拡張機能の例

Sub Initialize
	Dim winTitle As String, winTitleLength As Long
	winTitle$ = String(255, 0)
	Dim findWinTitle As String, tempWinTitle As String
	Dim curWin As Long, found As Integer
	tempWinTitle = "I'm working here now!"
	findWinTitle = Inputbox("What window do you want _
    to use?")
	If findWinTitle = "" Then Exit Sub
	curWin = GetActiveWindow
	Do While curWin <> 0
		curWin = GetWindow(curWin, GW_HWNDNEXT)
		winTitleLength = GetWindowText(curWin, winTitle, _
         255)
		If Instr(1, winTitle, findWinTitle, 1) > 0 Then
			found = True
			Exit Do
		End If
	Loop
	If found Then
		Call SetWindowText(curWin, tempWinTitle)
		Call SetActiveWindow(curWin)
		While GetActiveWindow = curWin
			Yield
		Wend
		winTitle = Left(winTitle, winTitleLength)
		Messagebox "Done working with " & winTitle & "!"
		Call SetWindowText(curWin, winTitle)
	Else
		Messagebox "Window not found!"
	End If
End Sub