gpt4 book ai didi

vba - Outlook 电子邮件中的文本框

转载 作者:行者123 更新时间:2023-12-04 03:12:18 25 4
gpt4 key购买 nike

下面是两组删除文本框的VBA代码,第一组适用于MS Excel,第二组适用于MS Word。两者之间唯一的区别是“Active”之后的第三行。

我正试图在一封新打开的电子邮件中在 MS Outlook 中复制此操作,但缺乏正确代码术语的知识...有没有人知道这个问题的答案?...谢谢, .

Sub RemoveTextBox()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Type = msoTextBox Then shp.Delete
Next shp
End Sub

Sub RemoveTextBox()
Dim shp As Shape
For Each shp In ActiveDocument.Shapes
If shp.Type = msoTextBox Then shp.Delete
Next shp
End Sub

最佳答案

对于 Outlook,它将类似于以下示例

Option Explicit
Public Sub Example()
Dim Inspector As Outlook.Inspector
Dim wdDoc As Word.Document
Dim Shp As Word.Shape

Set Inspector = Application.ActiveInspector()
Set wdDoc = Inspector.WordEditor

For Each Shp In wdDoc.Shapes

Debug.Print Shp.Type 'msoTextBox = 17 - Print on Immediate Window
If Shp.Type = msoTextBox Then Shp.Delete

Next

End Sub

使用 打开电子邮件 Application.ActiveInspector Method (Outlook) Inspector.WordEditor Property (Outlook)

Inspector.WordEditor Property (Outlook) Returns the Microsoft Word Document Object Model of the message being displayed. Read-only, The WordEditor property is only valid if the IsWordMail method returns True and the EditorType property is olEditorWord. The returned WordDocument object provides access to most of the Word object model except for the following members:


Application.ActiveInspector Method (Outlook) Returns the topmost Inspector object on the desktop.


Remember to add reference to word xx object library


1. From the Tools menu, choose References to display the References dialog box.

2. The References dialog box shows all object libraries registered with the operating system. Scroll through the list for the application whose object library you want to reference. If the application isn't listed, you can use the Browse button to search for object libraries (.olb and .tlb) or executable files (.exe and .dll on Windows). References whose check boxes are checked are used by your project; those that aren't checked are not used, but can be added.

关于vba - Outlook 电子邮件中的文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44054466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com