Word页眉中加文本框(100分)

  • 主题发起人 主题发起人 Haishen
  • 开始时间 开始时间
H

Haishen

Unregistered / Unconfirmed
GUEST, unregistred user!
请问,如何在Word的页眉中加入文本框,并写入我要的字呢
我在Word的宏中无法找到答案,我现在能加上文本框,但无法用程序选中它并写入内容

哪位知道,非常着急!!
 
Sub Macro1()
'
' Macro1 Macro
' 宏在 2002-12-26 由 dcs 录制
'
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.TypeText Text:="cfghdgftedgtre"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

以下代码:请打开demo 下面的actiex/oleauto/srvcomp/word
然后放一个buttom写以下代码:
var
dcs:OleVariant;
begin
with WordDocument do
begin
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes.Item(2).close;
If (ActiveWindow.ActivePane.View.Type_ = wdNormalView) Or
(ActiveWindow.ActivePane.View.Type_ = wdOutlineView) Then
ActiveWindow.ActivePane.View.Type_ := wdPrintView;
ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader;
activeWindow.Selection.TypeText('cfghdgftedgtre');
ActiveWindow.ActivePane.View.SeekView := wdSeekMainDocument;
end;


多么好,但需要在开始 uses activex或oledb
 
同意,使用录制的宏
 
你们并没有写明如何生成文本框呀,录制宏不能录文本框的创建的
 
Sub Macro3()
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
CommandBars("Control Toolbox").Visible = True
ActiveDocument.ToggleFormsDesign
Selection.InlineShapes.AddOLEControl ClassType:="Forms.TextBox.1"
'这句是文本框的创建
End Sub
 
后退
顶部