VBA/Excel/Access/Word/Word/Documents
Версия от 16:33, 26 мая 2010; (обсуждение)
Содержание
- 1 Changes all bold formatting in the open document named Example.doc to italic formatting.
- 2 Check the current document count
- 3 Loop through the Documents
- 4 To maximize, minimize, or "restore" a window, set its WindowState property to wdWindowStateMaximize, wdWindowStateMinimize, or wdWindowStateNormal, respectively
Changes all bold formatting in the open document named Example.doc to italic formatting.
Sub change()
With Documents("Example.doc").Content.Find
.ClearFormatting
.Font.Bold = True
With .Replacement
.ClearFormatting
.Font.Bold = False
.Font.Italic = True
End With
.Execute FindText:="A", ReplaceWith:="B", _
Format:=True, replace:=wdReplaceAll
End With
End Sub
Check the current document count
Sub box()
If Documents.Count = 0 Then
Proceed = MsgBox("no document.Please open a document.", vbOKCancel + vbExclamation, "Format Report")
If Proceed = vbOK Then
Dialogs(wdDialogFileOpen).Show
If Documents.Count = 0 Then End
Else
End
End If
End If
End Sub
Loop through the Documents
Sub forEach()
Dim Doc As Document
For Each Doc In Documents
Doc.Close SaveChanges:=wdSaveChanges
Next
End Sub
To maximize, minimize, or "restore" a window, set its WindowState property to wdWindowStateMaximize, wdWindowStateMinimize, or wdWindowStateNormal, respectively
Sub max()
With Documents("Example.doc").Windows(1)
If .WindowState = wdWindowStateMinimize Then _
.WindowState = wdWindowStateMaximize
End With
End Sub