gzygzy 发表于 2010-8-27 16:16:26

在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

saruman 发表于 2010-9-12 11:18:15

顶一下,真的无法解决?

xyold1 发表于 2010-9-12 18:34:51

autoit.send (s)

xyold1 发表于 2010-9-12 18:35:31

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' 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

以上代码编译通过

ndyndy 发表于 2010-9-13 13:56:45

office问题很头痛

newstar20088 发表于 2010-9-14 12:04:35

office问题很头痛
页: [1]
查看完整版本: 在EXCEL的VBA中使用autoit