4
我的代碼只是它其中的作品不與圖像添加簽名在Outlook中包括圖像。這裏的圖片是指公司徽標和社交網絡圖標。添加簽名使用Excel VBA
此代碼是用Excel VBA編寫的,目標是將範圍作爲圖片複製粘貼到Outlook電子郵件中。
Dim Rng As Range
Dim outlookApp As Object
Dim outMail As Object
Dim wordDoc As Word.Document
Dim LastRow As Long
Dim CcAddress As String
Dim ToAddress As String
Dim i As Long
Dim EndRow As String
Dim Signature As String
'// Added Microsoft word reference
Sub Excel_Image_Paste_Testing()
On Error GoTo Err_Desc
'\\ Define Endrow
EndRow = Range("A65000").End(xlUp).Row
'\\ Range for copy paste as image
Set Rng = Range("A22:G" & EndRow)
Rng.Copy
'\\ Open a new mail item
Set outlookApp = CreateObject("Outlook.Application")
Set outMail = outlookApp.CreateItem(0)
'\\ Display message to capture signature
outMail.Display
'\\ This doesnt store images because its defined as string
'Problem lies here
Signature = outMail.htmlBody
'\\ Get its Word editor
Set wordDoc = outMail.GetInspector.WordEditor
outMail.Display
'\\ To paste as picture
wordDoc.Range.PasteAndFormat wdChartPicture
'\\ TO and CC Address
CcAddress = "[email protected]"
ToAddress = "[email protected]"
'\\ Format email
With outMail
.htmlBody = .htmlBody & Signature
.Display
.To = ToAddress
.CC = CcAddress
.BCC = ""
.Subject = "Email Subject here"
.readreceiptrequested = True
End With
'\\ Reset selections
Application.CutCopyMode = False
Range("B1").Select
Exit Sub
Err_Desc:
MsgBox Err.Description
End Sub
請注意,這個文件將被分配給許多人,使他們有自己的默認簽名。所以我不知道默認的.htm簽名名稱。
(「應用程序數據\漫遊\微軟\簽名」)
的人也可能有許多簽名,但我的目標是奪取其默認簽名。
Error signature picture after running the code
我的簽名應該是如下圖所示VS錯誤一個在上面的鏈接。
感謝您亞洲時報Siddharth抽出時間和張貼對我來說。我的默認簽名在簽名內有自己的圖像。定義特定的圖像路徑將很困難,因爲該文件將被具有不同公司圖像的各種利益相關者使用 – vds1
您可以隨時將範圍保存爲用戶的本地臨時目錄的圖像,然後使用該路徑? –
查看更新後的帖子。您可能需要刷新頁面才能看到它。 –