起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 503|回复: 3

根据VBA转化操作word的代码

[复制链接]
发表于 2010-12-31 16:32:11 | 显示全部楼层 |阅读模式
我这里在word文件中有页眉信息,页眉中是个表格,需要向指定的单元格中插入值,录制的宏代码不懂,请求帮忙
分析分析:

Selection.TypeText Text:="1" ————行中

Selection.TypeText与 Text 中间是个空格,是什么关系?


附宏代码:
Sub Macro41111111()
'
' Macro41111111 Macro
' 宏在 2010-12-31 由 未定义 录制
'
    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
        ActivePane.View.Type = wdOutlineView Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.MoveRight Unit:=wdCharacter, Count:=5

    Selection.MoveDown Unit:=wdLine, Count:=1
    Selection.TypeText Text:="2"
    Selection.MoveDown Unit:=wdLine, Count:=1
    Selection.TypeText Text:="3"
    Selection.MoveRight Unit:=wdCharacter, Count:=9
    Selection.MoveLeft Unit:=wdCharacter, Count:=2
    Selection.TypeText Text:="4"
    Selection.MoveUp Unit:=wdLine, Count:=1
    Selection.TypeText Text:="5"
    Selection.MoveUp Unit:=wdLine, Count:=1
    Selection.TypeText Text:="6"
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    ActiveDocument.Save
End Sub

word截图.jpg

16.73 KB, 下载次数: 170

回复

使用道具 举报

发表于 2011-1-4 09:50:31 | 显示全部楼层
请楼主参考下该贴 http://bbs.justep.com/forum.php?mod=viewthread&tid=27065
对于vba的代码可以利用上面帖子中的3楼方法看看office的帮助或者网上找一下资料。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-1-10 17:44:19 | 显示全部楼层
zfang 给的连接中帖子很受用,谢谢啦,结贴!
回复 支持 反对

使用道具 举报

发表于 2011-1-11 13:23:13 | 显示全部楼层
客气,楼主可以把你的代码分享出来一下。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-5 06:48 , Processed in 0.044078 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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