Word中VB代码
="":=False, Replace, MatchWildcards.Execute findtext:=".ClearFormatting .Find .ClearFormatting .Font.Replacement.Font.Color = wdColorBlack ;, replacewith参考VBA代码:Sub Hi_UndBla() With ActiveDocument.Replacement.Underline = wdUnderlineSingle .Range;"。
如何在word宏里面写vb代码选中所有表格
ALT+F8,打开宏对话框,创建名为SelectAllTables的宏。代码如下:
Sub SelectAllTables()
Dim tempTable As Table
Application.ScreenUpdating = False
'判断文档是否被保护
If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
MsgBox "文档已保护,此时不能选中多个表格!"
Exit Sub
End If
'删除所有可编辑的区域
ActiveDocument.DeleteAllEditableRanges wdEditorEveryone
'添加可编辑区域
For Each tempTable In ActiveDocument.Tables
tempTable.Range.Editors.Add wdEditorEveryone
Next
'选中所有可编辑区域
ActiveDocument.SelectAllEditableRanges wdEditorEveryone
'删除所有可编辑的区域
ActiveDocument.DeleteAllEditableRanges wdEditorEveryone
Application.ScreenUpdating = True
End Sub
保存完成后选择加载该宏即可。
如何在word宏里面写vb代码选中所有表格
ALT+F8,打开宏对话框,创建名为SelectAllTables的宏。
代码如下: Sub SelectAllTables()Dim tempTable As TableApplication.ScreenUpdating = False'判断文档是否被保护If ActiveDocument.ProtectionType = wdAllowOnlyFormFields ThenMsgBox "文档已保护,此时不能选中多个表格!"Exit SubEnd If'删除所有可编辑的区域ActiveDocument.DeleteAllEditableRanges wdEditorEveryone'添加可编辑区域For Each tempTable In ActiveDocument.TablestempTable.Range.Editors.Add wdEditorEveryoneNext'选中所有可编辑区域ActiveDocument.SelectAllEditableRanges wdEditorEveryone'删除所有可编辑的区域ActiveDocument.DeleteAllEditableRanges wdEditorEveryoneApplication.ScreenUpdating = TrueEnd Sub保存完成后选择加载该宏即可。
vb 求代码 文字输入 WORD
'
'入口参数;Insert_String 是要插入的字符
'功能;在Word文档中插入字符 这个功能:如果文档被关闭后则会出错,否则可连续的插入字符
Public Function InsertString(ByVal Insert_String As String) As Boolean
On Error GoTo ONERROR
objApplication.Selection.TypeText Text:=Insert_String
objApplication.Visible = True '使程序可见
InsertString = True
Exit Function
ONERROR:
If Err.Number <> 0 Then
Select Case Err.Number
Case Else
MsgBox "错误代码:" & Err.Number & " 错误描述:" & Err.Description
InsertString = False
End Select
End If
End Function
插入前需要建立word文档对象.
VB如何读入Word的内容?用VB打开WORD,如何将其中的内容 爱问
Set oApp = CreateObject("Word。
Application") oApp。Visible = False Set oDoc = oApp。
Documents。Open(strFile)'strFile为文件路径 '获得最后一段的内容 Dim length As Long '整个文档的长度 Dim i As Long length = oDoc。
Content。StoryLength Content = oDoc。
Content。Text Dim s As String For i = 1 To length If Mid$(Content, i, 1) = Chr$(13) Then s = s + vbCrLf Else s = s + Mid$(Content, i, 1) End If Next i oDoc。
Close True oApp。Quit False txtMx = s。
转载请注明出处51数据库 » wordvb代码怎么写
亖呉?盀