My code creates a wordoc for a email

Eric Penfold

Active Member
Joined
Nov 19, 2021
Messages
431
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
This wordoc needs to have active hyper links on it.
Is it possible to make them activate on the wordoc or is their a different way of producing the link into the Email.
The code to create the wordoc is below

VBA Code:
Option Explicit
Sub SendDailyMailEmail()

    Dim wb     As Workbook
    Dim ws     As Worksheet
    Dim tbl    As Range
    Dim LRow   As Long
    Dim EmailApp As Object, EmailItem As Object
    Dim Pic    As Picture
    Dim WordDoc
    
    Set EmailApp = CreateObject("Outlook.Application")
    Set EmailItem = EmailApp.CreateItem(0)
    
    Set wb = Workbooks("MyPersonal.xlsb")
    Set ws = wb.Sheets("DailyMail")
    LRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
    Set tbl = ws.Range("A1:Q" & LRow)
    
    ws.Activate
    tbl.Copy
    Set Pic = ws.Pictures.Paste
    
    Pic.Select
    
    Pic.Cut
    
    With EmailItem
        .To = ""
        .Subject = "Daily Mail" & " " & Format(Date, "dd-mm-yy")
        .Display
        
        Set WordDoc = EmailItem.GetInspector.WordEditor
        With WordDoc.Range
            .PasteAndFormat 13
            .InsertParagraphafter
            .InsertParagraphafter
            .InsertAfter "Kind Regards,"
        End With
    End With
    On Error GoTo 0
    
     With EmailItem
            .To = strStaffEmails
            .CC = ""
            .Subject = "Daily Mail"
      End With
                        
    Set EmailItem = Nothing
    Set EmailApp = Nothing
    
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,223,952
Messages
6,175,594
Members
452,655
Latest member
goranzoric

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top