找回密码
 加入
搜索
查看: 5780|回复: 9

[系统综合] 在word中怎样把光标定位到指定位置

  [复制链接]
发表于 2012-3-30 13:11:06 | 显示全部楼层 |阅读模式
在word中怎样把光标定位到指定位置,比如:
aabbcc
ccddee
我要把光标定位到第二行的cc后
发表于 2012-3-30 13:34:21 | 显示全部楼层
在word中怎样把光标定位到指定位置,比如:
aabbcc
ccddee
我要把光标定位到第二行的cc后
ndyndy 发表于 2012-3-30 13:11


用VBA,若不知如何写,在Word录个宏,查看这个宏就知道如何写了
再用Au3建个Word对象操作就要以了
发表于 2012-3-30 16:11:19 | 显示全部楼层
本帖最后由 kevinch 于 2012-3-30 16:12 编辑
$word=ObjCreate("word.application")
$word.visible=True
$doc=$word.documents.add
$doc.range.text="aabbcc"&@CRLF&"ccddee"
With $doc.parent.selection.find
        .clearformatting
        .replacement.clearformatting
        .text="cc"
        $n=0
        Do
                .execute
                If .found Then 
                        $n+=1
                Else
                        ExitLoop
                EndIf
        Until $n=2
        If $n=2 Then
                .parent.moveright
                .parent.typetext("光标就位了")
        Else
                MsgBox(0,"","没找到那么多!")
        EndIf
EndWith
测试代码

评分

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

查看全部评分

 楼主| 发表于 2012-3-30 16:18:49 | 显示全部楼层
这下不用靠宏了,谢谢
发表于 2012-3-30 16:38:23 | 显示全部楼层
这个很像是木马呀
发表于 2012-3-30 16:38:30 | 显示全部楼层
这个很像是木马呀1
 楼主| 发表于 2012-3-30 16:40:21 | 显示全部楼层
回复 3# kevinch
kevinch老大怎样才能把某一行或某一指定字符的字体变色如:
aaabbbccc
dddeeefff
把aaabbbccc行变红
把eee变蓝
 楼主| 发表于 2012-3-30 16:47:22 | 显示全部楼层
不是木马是要把log文件粘贴到DOC上
发表于 2012-3-30 18:10:12 | 显示全部楼层
$word=ObjCreate("word.application")
$word.visible=True
$doc=$word.documents.add
$doc.range.text="aaabbbccc"&@crlf&"dddeeefff"
With $doc.parent.selection.find
        .clearformatting
        .replacement.clearformatting
        .forward=1
        .wrap=0
        .text="aaabbbccc"
        While 1
                .execute
                If .found Then 
                        .parent.homekey(5)
                        .parent.endkey(5,1)
                        .parent.font.colorindex=6
                        .parent.endkey
                Else
                        ExitLoop
                EndIf
        wend
        .text="eee"
        While 1
                .execute
                If .found Then
                        .parent.font.colorindex=2
                Else
                        ExitLoop
                EndIf
        WEnd
        .parent.homekey(6)
EndWith
发表于 2012-12-15 11:37:53 | 显示全部楼层
非常好!正需要
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-6 19:47 , Processed in 0.075633 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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