我尝试创建一个宏来设置Outlook电子邮件中的选择语言.
我在VBA脚本方面经验不足.
我将我在Word中录制的宏复制到我的Outlook宏窗口(或项目,或模块,我不知道它是如何命名的)
Sub SelectionEnglish()
Selection.LanguageID = wdEnglishUS
Selection.NoProofing = False
Application.CheckLanguage = True
End Sub
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为Selection对象不可用.但我看到了另一个问题(我再也找不到了)宏观作者在outlook宏中使用word-editor的方法.
是的,电子邮件正文中的文本选择 - tjb 21分钟前
试试这个(从Outlook VBA运行)在新创建的电子邮件上试用和测试.此代码显示如何使用SelectionObject
Sub Sample()
Dim oMailItm As Object, oInsp As Object, oMailEd As Object
Dim oWord As Object, rng As Object
Set oInsp = Application.ActiveInspector
If oInsp.CurrentItem.Class = olMail Then
Set oMailItm = oInsp.CurrentItem
If oInsp.EditorType = olEditorWord Then
Set oMailEd = oMailItm.GetInspector.WordEditor
Set oWord = oMailEd.Application
'~~> Set your selection object here
Set rng = oWord.Selection
'~~> This is to check if we are getting the selection object
'~~> You may comment this or remove it later.
MsgBox rng.Text
With rng
'
'~~> Rest of the code
'
End With
End If
End If
Set rng = Nothing
Set oWord = Nothing
Set oMailEd = Nothing
Set oMailItm = Nothing
Set oMailItm = oInsp
End Sub
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1268 次 |
| 最近记录: |