
更新:更新了巨集並修復。
版本:Outlook 2013
我希望能夠...
- 更改表格中文字的字體大小。(完畢)
- 從表格、列和儲存格活動屬性中刪除(取消選取)「首選寬度」屬性。
- 從表格的行中刪除(取消選取)「指定高度」屬性。
如果我使用aTbl.Columns.PreferredWidth = Unchecked
壓縮列,它會自動換行並且不會取消選取該方塊。我希望它不自動換行。
如果我使用 autoFit,它看起來與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