Hi All,

I have tried to copy over a macro from a different workbook that works absolutely fine, but when I pasted the code below into a module of my new workbook I get the error Compile error: User-defined type not defined on the line:
Dim olApp As Outlook.Application
The macro prepares and populates a new email with specified text and part of the workbook pasted into the email. I don't understand why this worked perfectly well in the old workbook, but by transferring it into the new one it stops functioning? The full code is blow:

Sub SendRequest()
 
 Application.ScreenUpdating = False
 Application.DisplayAlerts = False

 Dim olApp As Outlook.Application
 Dim olEmail As Outlook.MailItem
 Dim OlInsp As Outlook.Inspector
 Dim strGreeting As String
 
 strGreeting = "EMAIL TEXT HERE."
 
 Set olApp = New Outlook.Application
 Set olEmail = olApp.CreateItem(olMailItem)
 
    With olEmail
        .BodyFormat = olFormatHTML
        .Display
    
        .To = "EMAIL ADDRESS"
        .Subject = "SUBJECT TEXT"
    
        Set OlInsp = .GetInspector
        Set WdDoc = OlInsp.WordEditor
    
        WdDoc.Range.InsertBefore strGreeting
    
        Sheet1.Activate
        Range("COPYRANGE").Copy
        
        WdDoc.Range(Len(strGreeting), Len(strGreeting)).Paste
    
    End With
    
  Application.CutCopyMode = False

  
End Sub