I'm currently testing the usability of the global Word template thats to be implemented across the firm and I got this error (see screenshot) when testing the email function (see posted code). Any thoughts as to why this is happening and what I can do to go around it woudl be greatly appreciated.
Thanks in advance
Andrew;?
[vba]
Sub DoEmail()
Dim OL As Object
Dim EmailItem As Object
Dim hLink As Range
Dim Doc As Document
Dim emailitem2 As Outlook.Application
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application") 'this line gives the error
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
FileNameForEmail = Doc.Name
FilePathForEmail = Doc.Path + Doc.Name
Doc.Save
With EmailItem
.Subject = "For your review"
.Importance = olImportanceNormal
.Display
Set hLink = ActiveDocument.Content
ActiveDocument.ActiveWindow.Activate
hLink.Select
Selection.TypeText Text:="Press <CTRL> + click on the link to review _
the document (" + FileNameForEmail + ")" + vbCrLf
hLink.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
FilePathForEmail, SubAddress:="", TextToDisplay:=FileNameForEmail
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub
[/vba]
forgot to add that all the office references have been added to the template in the VBE.