更新:已更新宏并修复。
版本:Outlook 2013
我希望能够...
- 改变表格中文本的字体大小。(完毕)
- 从表、列和单元格活动属性中删除(取消选中)“首选宽度”属性。
- 从表的行中删除(取消选中)“指定高度”属性。
如果我使用aTbl.Columns.PreferredWidth = Unchecked
压缩列,它会进行自动换行,并且不会取消选中该框。我希望它不进行自动换行。
如果我使用自动调整,它看起来与 相同aTbl.Columns.PreferredWidth = Unchecked
。
如果我单独设置列,它看起来与相同aTbl.Columns.PreferredWidth = Unchecked
。
必须导入 MS Word 对象库:
我目前拥有的:
Public Sub FormatSelectedText()
Dim objItem As Object
Dim objInsp As Outlook.Inspector
' Add reference to Word library in VBA Editor, Tools, References
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim objSel As Word.Selection
'On Error Resume Next
'Reference the current Outlook item
Set objItem = Application.ActiveInspector.CurrentItem
If Not objItem Is Nothing Then
If objItem.Class = olMail Then
Set objInsp = objItem.GetInspector
If objInsp.EditorType = olEditorWord Then
Set objDoc = objInsp.WordEditor
Set objWord = objDoc.Application
Set objSel = objWord.Selection
objSel.Font.Size = 8
Dim aTbl As Word.Table
For i = 1 To objSel.Tables.Count()
Set aTbl = objSel.Tables.Item(i)
aTbl.Borders.InsideLineStyle = wdLineStyleSingle
aTbl.Borders.OutsideLineStyle = wdLineStyleSingle
aTbl.Rows.Height = Unchecked
aTbl.Rows.AllowBreakAcrossPages = False
aTbl.Columns.PreferredWidth = Unchecked
aTbl.Columns.PreferredWidthType = wdPreferredWidthAuto
aTbl.PreferredWidth = Unchecked
Next
End If
End If
End If
Set objItem = Nothing
Set objWord = Nothing
Set objSel = Nothing
Set objInsp = Nothing
End Sub
脚本之前的样子:
预期结果:
运行后aTbl.Columns.PreferredWidth = Unchecked
(关闭但不压缩列):
跑步后aTbl.Columns.PreferredWidth = Unchecked
(只是..没有):
为了正确修改表格需要更改的设置示例:
答案1
对我来说这是有效的:
aTbl.Columns.PreferredWidth = Unchecked
aTbl.Columns.PreferredWidthType = wdPreferredWidthAuto