属性值N = 0 – 100。把window分成上下2个panes,上pane的高度占window高度的N%。每个pane显示的是同一文档,但有自己的Scrollbar, 有自己的Selection或插入点,从而可以看到文档的不同部分。在每个pane上进行的编辑,在另一pane上当然也可看到,因为是同一文档。 即使在Normal View,下pane也可以不显示正文,而专门显示如Comments,Footnotes等,由window.View.SplitSpecial属性<>0指示。
N=0表示取消split,即window是单个Pane,与Split=False同效。 也可以用window.Panes.Add方法来split。
(交互式:Wibdow->Split 或 Window-Remove Split ) Split 属性:read/write True/False. (Window object)
Read: 返回T/F,表示window当前是否已分panes。
Write: 如果window还未split,则置Split属性为True时,该window被平分成上下2个panes,同window.SplitVertical=50。如果已split,写True则等于没写,写False则是去掉Panes,即整个window变成单个Pane。
View属性(Window object, Pane Object)
指向View object。
在Tools->Options->View tab中的options设置要通过ActiveDocument.ActiveWindow.View的属性来读写。
View object
注:Window和Pane objects都有下属的View object。View object的有些属性/方法只能用于 window.View object,而不能用于window.Pans(i).View object。 属性: Type,FullScreen,SplitSpecial
ShowStatusbar,ShowBookmarks,ShowFieldCodes,ShowParagraphs, ShowHiddenText,ShowTextBoundaries,ShowTabs,ShowSpaces, ShowDrawings, … …
方法: ShowHeading, AhowAllHeadings,
ExpandOutline,CollapseOutline, NextHeaderFooter,PreviousHeaderFooter
Type属性:Read/write Long. (window.View object) Returns or sets the view type.
Can be one of the following WdViewType constants:
WdMasterView(5), wdNormalView(1), wdOutlineView(2),
WdPrintPreview(4), wdPrintView(3), or wdWebView(6). SplitSpecial属性: ( window.View object only) Read/write Long.
Returns or sets the active window pane. Can be one of the following WdSpecialPane constants:
wdPaneNone(0)
wdPaneCurrentPageFooter, wdPaneCurrentPageHeader wdPaneFirstPageFooter, wdPaneFirstPageHeader wdPanePrimaryFooter, wdPanePrimaryHeader
wdPaneEvenPagesFooter, wdPaneEvenPagesHeader, WdPaneComments(15)
wdPaneFootnoteContinuationNotice, wdPaneFootnoteContinuationSeparator
wdPaneFootnotes, wdPaneFootnoteSeparator
wdPaneEndnoteContinuationNotice, wdPaneEndnoteContinuationSeparator wdPaneEndnotes, wdPaneEndnoteSeparator
写SplitSpecial属性可以Split(如果原未Split),并指定低pane用来显示什么。
但再一次置SplitSpecial属性为同一值,则取消split了(SplitSpecial变成wdPaneNone)。 例:下面的pane,用来显示Footnotes:
If ActiveDocument.ActiveWindow.Panes.Count=1 Then With ActiveDocument.ActiveWindow.View .Type = wdNormalView
.SplitSpecial = wdPaneFootnotes End With End If
Panes属性 (window object) Panes collection
属性: Count 方法: Item,Add Pane object
属性: Index, BrowseWidth,DisplayRulers,DisplayVerticaRuler, HorizontalPercentScrolled, VerticalPercentScrolled, MinimunFontSize, Frameset,
Next,Previous,Selection, Document, View, Zooms, Parent,Creator,Application 方法: Activate,Close,
AutoScroll,LargeScroll,SmallScroll,PageScroll, NewFrameset,TOCInFrameset
Zooms Property (Pane object)
Read-only. Returns a Zooms collection. Zooms Collection
包含6 个Zoom objects 。
方法/属性:只有 Item; Parent,Creator,Application Zooms(index)返回Zoom object ,其中index是 View Type:
WdMasterView(5), wdNormalView(1), wdOutlineView(2), WdPrintPreview(4), wdPrintView(3), or wdWebView(6).
Zoom object
每个pane用一Zoom对象window.Panes(i).Zooms(k)表示在特定view 类型k下的zoom 特性. window如果未split,用window.View.Zoom指向该View类型下的Zoom对象。即如果当前的 View.Type=k时,window.View.Zoom和window.Panes(1).Zooms(k)同效。 Zoom object 只有以下属性,用来表示zoom 特性:
Percentage, PageFit, PageRows, PageColumns (and Parent,Creator,Application)
Percentage属性:值N 表示Pane显示内容的缩放比例为 N%, N<100:缩小,N>100:放大。 N=100 表示恢复原状,不缩放。
注:window本身的size不变。放的太大,一行只能看到前面的部分了。
写Percentage属性后PageFit自动变成default(WdPageFitNone)。因此 Percentage和PageFit,只能用其一来zoom。彼此相互Override。
例:
With ActiveDocument.ActiveWindow.View .Type = wdNormalView
.Zoom.Percentage = .Zoom.Percentage + 10 End With
With ActiveDocument.ActiveWindow.ActivePane
.Zooms(wdNormalView).Percentage = .Zooms(wdNormalView).Percentage + 10 End With
PageFit属性: Read/write Long. 值可以是:
wdPageFitBestFit:随当前window size自动调整Percentage,使每行都完整显示,但放大 的比例尽可能大。
WdPageFitFullPage: in print view only 。 显示整页。 WdPageFitNone: default,只按Percentage缩放。 WdPageFitTextFit:(看不到效果。) 例:
With ActiveDocument.ActiveWindow.View .Type = wdNormalView
.Zoom.PageFit = wdPageFitBestFit End With
PageRows属性: Read/write Long. 值m, default=1 。 PageColumns属性: Read/write Long. 值n, default=1 。
在窗口中显示MxN页。呈 m行n列状。in print layout view/Preview only。 例.显示上下2页:
PrintPreview = True
With ActiveDocument.ActiveWindow.View.Zoom .PageColumns = 1 .PageRows = 2 End With
Dialogs
Dialogs Property ( Application/Global object)
Returns a Dialogs collection that represents all the built-in dialog boxes in Word.
Dialogs Collection
属性/方法: Count,Parent,Creator,Application; Item
Dialogs(index): index必须是wdWordDialig常数,如
wdWorgDialogFileOpen, wdWordDialogEditFind, …… 常数名的构成规则是 wdWordDialog + Menu名+Command名。 例:
With Dialogs(wdDialogFileOpen) .Name = \
.Show End With
Dialogs(wdDialogFilePrint).Execute
Dialog object
属性:Type,CommandName,DefaultTab,Parent,Creator,Application 方法:Display,Show, Execute,Update
Type属性:Read only. 是该Dialog的wdWordDialig常数 CommandName属性:Read only.是该Dialog的Procedure名。
例如: MsgBox Dialogs(wdDialogCopyFile).Type ?300, i.e. wdDialogCopyFile MsgBox Dialogs(wdDialogCopyFile).CommandName ?CopyFileA MsgBox Dialogs(wdDialogFileOpen).CommandName ?FileOpen
DefaultTab 属性:Read /Write, WdWordDialogTab constants
指定当该Dialog Box显示时,对话框的哪一tab(如果有多个tabs)被激活。 如wdDialogFormatFont dialog box有3个tabs:
WdWordDialogFormatFontTabFont, WdWordDialogFormatFontTabCharracterSpacing, WdWordDialogFormatFontTabAnimation
其他属性:Dialog object还有其他属性,依赖于dialog.Type。
你可设置这些属性,相当于在对话框上设置options。例如:
With Dialogs(wdDialogEditFind)
.Find = \‘ set “Find What” text .Show End With
With Dialogs(wdDialogFileOpen) .Name = \ .Show End With
Display方法 (Dialog object)
Displays the specified built-in Word dialog box until either the user closes it or the specified amount of time has passed. Syntax dialogObj.Display(TimeOut)
TimeOut Optional Variant. The amount of time that Word will wait before closing the dialog box automatically. One unit is approximately 0.001 second. Concurrent system activity may increase the effective time value. If this argument is omitted, the dialog box is closed only when the user closes it.
Returns a Long that indicates which button was clicked to close the dialog box:
Return value Description
-2 The Close button.
-1 The OK button. (自注:For SaveAs Dialog box, Save button) 0 (zero) The Cancel button.
(自注:For SaveAs Dialog, Cancel button or Close Button) > 0 (zero) A command button: 1 is the first button, 2 is the second button, and so on.
Note Any actions initiated or settings specified while a dialog box is displayed using
Display method aren't carried out. Use the Show method to display a dialog box and carry out actions or apply settings.
Example This example displays the About dialog box.
Set aDialog = Dialogs(wdDialogHelpAbout) aDialog.Display
Show 方法 ( Dialog object )
Displays and carries out actions initiated in the specified built-in Word dialog box. Syntax dialogObj.Show(TimeOut) 返回值同Display方法。
自注:Display方法只显示对话框,不管用户按
ActiveDocument.Paragraphs(8).Range.Select With Dialogs(wdDialogFormatParagraph)
.KeepWithNext = 1 (Checkbox = true, 置-1是灰的) .Display 'Show 'Execute End With
DialogObj.Update方法(也不显示对话框)是用当前Selection 来更新dialogObj对话框中的Options。然后你可接着再Display, Show,或Execute。
但若对话框提供的不是
ActiveDocument.Paragraphs(9).Range.Select With Dialogs(wdDialogEditFind) .Find = \
.Display 'Execute 'Show End With
Show时,立刻执行了查找并找到了第一个 “W”(假设有),你可以再按
Execute方法 ( Dialog Objects)
Syntax dialogObj.Execute
Applies the current settings of a Word dialog box. Execute方法并不显示对话框。作用相当于.Show后按了
The following example enables the Keep with next check box on the Line and Page Breaks tab in the Paragraph dialog box .
ActiveDocument.Paragraphs(1).Range.Select With Dialogs(wdDialogFormatParagraph) .KeepWithNext = 1
.Execute 将wdDialogFormatParagraph对话框的 Format设置应用于Paragraph 1。 End With
附:KeyBinding Object和MailMerge object也有Execute方法
KeyBindingObj.Execute
Runs the command associated with the specified key combination.
This example assigns the CTRL+SHIFT+C key combination to the FileClose command and then executes the key combination (the document is closed).
CustomizationContext = ActiveDocument.AttachedTemplate Keybindings.Add KeyCode:=BuildKeyCode(wdKeyControl, _
wdKeyShift, wdKeyC), KeyCategory:=wdKeyCategoryCommand, _ Command:=\
FindKey(BuildKeyCode(wdKeyControl, wdKeyShift, wdKeyC)).Execute
搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新IT计算机Word VBA(2) (7)全文阅读和word下载服务。
相关推荐: