Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 删除“删除”;与整张表相同”;Outlook表中的属性_Vba_Ms Word - Fatal编程技术网

Vba 删除“删除”;与整张表相同”;Outlook表中的属性

Vba 删除“删除”;与整张表相同”;Outlook表中的属性,vba,ms-word,Vba,Ms Word,我有以下代码来“编码”outlook邮件中的代码块: On Error GoTo Catch Dim oSelection As Word.Selection Set oSelection = Application.ActiveInspector.CurrentItem.GetInspector.WordEditor.Application.Selection With oSelection With .Font .Name = "Courier New"

我有以下代码来“编码”outlook邮件中的代码块:

On Error GoTo Catch
Dim oSelection As Word.Selection
Set oSelection = Application.ActiveInspector.CurrentItem.GetInspector.WordEditor.Application.Selection

With oSelection
    With .Font
        .Name = "Courier New"
        '.Color = 10027008 '13369344
        .Size = 10
    End With
End With

Dim oTable As Word.Table
Set oTable = oSelection.ConvertToTable(, 1, 1)
With oTable
    .Borders.OutsideLineStyle = wdLineStyleDot
    .Shading.BackgroundPatternColor = wdColorGray05
    .TopPadding = InchesToPoints(0.1)
    .BottomPadding = InchesToPoints(0.1)
    .LeftPadding = InchesToPoints(0.2)
    .RightPadding = InchesToPoints(0.05)
End With
很好,但我认为我无法使用边距,因为我缺少删除“与整个表相同”属性的内容

代码运行后,表属性如下所示:


也许我只是把边距设置错了,这会自动消失吗?我缺少什么?

Word提供了一个宏记录器,可以在后台生成VBA代码。尝试在Word中录制VBA宏,并查看该宏应使用哪些属性。有关更多信息,请参阅

我的错

事实证明,设置填充是关闭此属性的方法。问题实际上出在我在MS Word中录制宏时复制和粘贴的
InchesToPoints
调用中

但是
在EstoPoints
中是/不是一个可用的方法,并且我的代码的第一行隐藏了该问题:

On Error Goto Catch
(现在就开枪!)

因此,
InchesToPoints
失败,这意味着实际上没有设置填充。我制定了自己的
InchesToPoints
方法:

Public Function InchesToPoints(ByVal dInches As Double) As Double
    Const INCHES_TO_POINTS = 72#
    InchesToPoints = dInches * INCHES_TO_POINTS
End Function
现在一切都很好

此问题的实际正确答案是设置表格填充(例如,
.TopPadding=7.2
将关闭“与整个表格相同”属性。


祝您度过愉快的一天。

事实上,我试过了。录制时,您不能右键单击表格来获取“表格属性”。此外,使用工具栏来获取属性不会显示与Outlook相同的弹出窗口(Outlook中也没有宏录制)。Word版本没有“与整个表格相同”属性。