找回密码
 加入
搜索
查看: 3602|回复: 5

[系统综合] 在EXCEL的VBA中使用autoit

  [复制链接]
发表于 2010-8-27 16:16:26 | 显示全部楼层 |阅读模式
本帖最后由 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
发表于 2010-9-12 11:18:15 | 显示全部楼层
顶一下,真的无法解决?
发表于 2010-9-12 18:34:51 | 显示全部楼层
autoit.send (s)
发表于 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
以上代码编译通过

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

发表于 2010-9-13 13:56:45 | 显示全部楼层
office问题很头痛
发表于 2010-9-14 12:04:35 | 显示全部楼层
office问题很头痛
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 21:53 , Processed in 0.079548 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表