网上有一段在Outlook新邮件中向光标所在处插入一段新文字 但是是.NET 程序, 原文地址http://blog.csdn.net/tx_officedev/article/details/7062770 如何将其转化为VBA??? 急需要。。。。谢谢 - Imports Microsoft.Office.Tools.Ribbon
- Imports Word = Microsoft.Office.Interop.Word
- Public Class Ribbon1
- Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As _
- RibbonUIEventArgs) Handles MyBase.Load
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
- Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles Button1.Click
- Dim objApplication As Outlook.Application
- Dim objInspector As Outlook.Inspector
- Dim objDocument As Word.Document
- Dim objSelection As Word.Selection
- Dim objRange As Word.Range
- Try
- objApplication = Globals.ThisAddIn.Application
- objInspector = objApplication.ActiveInspector
- objDocument = TryCast(objInspector.WordEditor, Word.Document)
- If objDocument IsNot Nothing Then
- objSelection = objDocument.Application.Selection
- objRange = objSelection.Range
- objRange.InsertAfter("This is a Test")
- objRange.Collapse(Word.WdCollapseDirection.wdCollapseEnd)
- objRange.Select()
- End If
- Catch ex As Exception
- MsgBox("Stack:" + Chr(13) + ex.StackTrace + Chr(13) + "Message:" + _
- Chr(13) + ex.Message, Title:="OutlookAddIn24 Exception")
- End Try
- End Sub
- End Class
|