找回密码
 加入
搜索
查看: 7027|回复: 10

关于EXCEL的问题---AUTOIT

  [复制链接]
发表于 2009-7-18 09:58:45 | 显示全部楼层 |阅读模式

1.如何可以快捷打印?


2.如何选定指定的工作表,如我要选择工作表"3",可以实现吗?

3.如何检测出已经打开了多少个EXCEL表格?

4.如何检测出已经打开了多少个WORD文档?如何在两个(或更多)WORD之间切换.

我在做一个多表格多文档自动打印时遇到的问题,不知用什么办法了,请大家看看可不可以实现上述条件,谢谢!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2009-7-20 09:31:36 | 显示全部楼层
顶起来一下。。。
发表于 2009-7-20 10:33:28 | 显示全部楼层
各种Excel VBA的命令
本文来自学习网(www.gzu521.com),原文地址:http://www.gzu521.com/campus/article/software/200809/174773.htm
发表于 2009-7-20 14:29:52 | 显示全部楼层
1.关于快速打印
ShellExecute("myfile.txt", "", @ScriptDir,'print')
是可以完美执行快速打印
ShellExecute("Book1.xls",'',@ScriptDir,'print')
就不行了
在帮助文件UDF里面有_WordDocPrint 这个函数,但却没有_ExcelPrint
上官网搜了一下
有个网友自己写了一个
不过我电脑装的是精简版office,_Excel和_Word一直都是执行出错,没办法测试了
自己试试:
; test for printing 
_ExcelPrint($oExcel);

; .. and in the UDF add 
;
; print current active worksheet 
;
Func _ExcelPrint($oExcel)
If NOT IsObj($oExcel) Then Return SetError(1, 0, 0)


; for information about currrent active printer
; MsgBox(1, "printer" , $oExcel.ActivePrinter);

;$oExcel.ActivePrinter="Adobe PDF auf NE03:" ; e.g for printing into PDF on my machine .. 

$oExcel.ActiveWorkbook.PrintOut() ;

Return 1
EndFunc 
2.如何选定指定的工作表,如我要选择工作表"3",可以实现吗?
ExcelSheetActivate
Activate the specified sheet by string name or by number
在帮助文件Excel UDF里面有例子

评分

参与人数 1金钱 +10 贡献 +10 收起 理由
kn007 + 10 + 10 我很赞同

查看全部评分

发表于 2009-7-20 15:06:19 | 显示全部楼层
3.如何检测出已经打开了多少个EXCEL表格?
#include <winapi.au3>
Local  $iProcessID
$pid=ProcessExists("EXCEL.exe")
Sleep(1000) 
$wlis=WinList()
$excelnumber=0
for $i=1 to $wlis[0][0]
        if $wlis[$i][0]<> "" AND IsVisible($wlis[$i][1]) then
_WinAPI_GetWindowThreadProcessId($wlis[$i][1], $iProcessID) 
If StringInStr($wlis[$i][0], "Microsoft Excel") then 
        $excelnumber=$excelnumber+1

EndIf
EndIf
Next
MsgBox(0,'',"目前打开了"&$excelnumber&'个EXCEL表格')

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf
EndFunc
4.如何检测出已经打开了多少个WORD文档?
#include <winapi.au3>
Local  $iProcessID
$pid=ProcessExists("WORD.exe")
Sleep(1000) 
$wlis=WinList()
$excelnumber=0
for $i=1 to $wlis[0][0]
        if $wlis[$i][0]<> "" AND IsVisible($wlis[$i][1]) then
_WinAPI_GetWindowThreadProcessId($wlis[$i][1], $iProcessID) 
If StringInStr($wlis[$i][0], "WORD") then 
        $excelnumber=$excelnumber+1

EndIf
EndIf
Next
MsgBox(0,'',"目前打开了"&$excelnumber&'个WORD')

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf
EndFunc
如何在两个(或更多)WORD之间切换.
_WordAttach 貌似能办到

评分

参与人数 2金钱 +20 贡献 +10 收起 理由
yangh71 + 10 很好滴参考资料
kn007 + 10 + 10 我很赞同

查看全部评分

 楼主| 发表于 2009-7-20 17:35:13 | 显示全部楼层
谢谢lynfr8 的回复.
2.如何选定指定的工作表,如我要选择工作表"3",可以实现吗?
ExcelSheetActivate
Activate the specified sheet by string name or by number
在帮助文件Excel UDF里面有例子

ExcelSheetActivate 这个好像只能新打开一个EXCEL,再激活工作表.
如果是激活当前已经打开的EXCEL的工作表就好了.
发表于 2009-7-20 17:45:32 | 显示全部楼层
激活当前已经打开的EXCEL的工作表


_ExcelBookAttach
认真研究下这个函数

我电脑装的是精简版office,_Excel和_Word一直都是执行出错,没办法测试
也懒得重装了
其他人跟上帮楼主测试解答吧
发表于 2009-7-20 18:02:28 | 显示全部楼层
学习。。。学习
发表于 2010-4-2 22:46:19 | 显示全部楼层
学习一下!!
发表于 2010-4-2 23:40:06 | 显示全部楼层
学习学习   !!
发表于 2010-4-25 16:19:47 | 显示全部楼层
学习一下!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-22 07:39 , Processed in 0.080663 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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