在EXCEL的VBA中使用autoit
本帖最后由 gzygzy 于 2010-8-27 16:18 编辑我在EXCEL中的VBA中代码中调用AUTOIT,
其中要发送一个字符串的变量,请教各位大侠,这个变量应该如果写才能被autoit.send 发送成功。谢谢!
If Target.Column = 11 And Target.Value <> "" And Target.Count = 1 Then
Dim s As String
s = Target.Value
Set autoit = CreateObject("AutoItX3.Control")
autoit.WinActivate ("Adobe Photoshop")
autoit.send ("^o")
autoit.send ("{$s}") 'S变量要怎样才能被AUTOIT.SEND正确引用
autoit.send ("!o")
End If 顶一下,真的无法解决? autoit.send (s) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Example WSH Script (VBScript)
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Require Variants to be declared before used
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Declare Variables & Objects
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim oShell
Dim oAutoIt
dim s
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Initialise Variables & Objects
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set oShell = WScript.CreateObject("WScript.Shell")
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Start of Script
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
WScript.Echo "这个VBS脚本将会打开记事本并输入一些文本"
oShell.Run "notepad.exe", 1, FALSE
' Wait for the Notepad window to become active
oAutoIt.WinWaitActive "无标题 - 记事本", ""
s="记事本"
' Send some keystokes to notepad
oAutoIt.Send "Hello, this is line 1{ENTER}"
oAutoIt.Send "This is line 2{ENTER}This is line 3"
oAutoIt.Send s
oAutoIt.Sleep 3000
oAutoIt.Send "!{F4}"
oAutoIt.WinWaitActive "记事本", "文件"
oAutoIt.Send "!n"
oAutoIt.WinWaitClose "无标题 - 记事本", ""
WScript.Quit
以上代码编译通过 office问题很头痛 office问题很头痛
页:
[1]