+ Reply to Thread
Results 1 to 2 of 2

Compile error user defined type not defined

  1. #1
    Registered User
    Join Date
    07-19-2015
    Location
    Alsdorf, Germeny
    MS-Off Ver
    2013
    Posts
    11

    Compile error user defined type not defined

    Hello Forum,

    Ive taken the code down below from another sheet on which this code is working.

    Now the Makro " BeginnMail " gives me a compile Error as written in the Title.

    Can somebody help me?

    Furthermore Id like to put the subject of the mnail together from 2 cells and a fix text.


    Option Explicit

    Sub Outlookliste()
    ' Demo fuer Outlook-Steuerung
    ' Geht Projektliste durch und erzeugt E-Mails
    Dim objEckzelle As Range
    Dim i As Long
    Dim lngZeilen As Long
    Dim datVergleichsdatum As Date
    Dim objOutlook As Outlook.Application

    On Error GoTo Fehler
    Set objEckzelle = Worksheets("Daten").Range("A1")
    ' Zeilenzahl auslesen
    lngZeilen = objEckzelle.CurrentRegion.Rows.Count
    datVergleichsdatum = Date + 1

    Set objOutlook = CreateObject("Outlook.Application")

    ' Schleife ueber Zeilen der Liste
    With objEckzelle
    For i = 2 To lngZeilen
    'If UCase(.Cells(i, 4)) <> "X" Then
    If .Cells(i, 14).Value = datVergleichsdatum Then
    ' Call MsgBox(.Cells(i, 1) & ": Beginnmail")
    Call BeginnMail(objOutlook:=objOutlook, _
    strBetreff:=.Cells(i, 1), _
    strAdresse:=.Cells(i, 28), _
    strMailtext:=.Cells(i, 2))
    End If
    ' If .Cells(i, 8).Value = datVergleichsdatum Then
    ' Call MsgBox(.Cells(i, 1) & ": Endemail")
    ' Call BeginnMail(objOutlook, .Cells(i, 1), .Cells(i, 28), .Cells(i, 2))
    ' End If
    'End If
    Next
    End With

    Ende:
    Set objOutlook = Nothing

    Exit Sub
    Fehler:
    Call MsgBox(Err.Number & vbNewLine & Err.Description)
    Resume Ende
    Resume

    End Sub

    Private Sub BeginnMail( _
    ByRef objOutlook As Outlook.Application, _
    ByVal strBetreff As String, _
    ByVal strAdresse As String, _
    ByVal strMailtext As String)

    Dim objMail As Outlook.MailItem

    Set objMail = objOutlook.CreateItem(olMailItem)
    With objMail
    .To = strAdresse
    .Body = strMailtext
    .Subject = strBetreff
    .Display
    End With

    End Sub
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    09-10-2014
    Location
    Matrix
    MS-Off Ver
    2010
    Posts
    68

    Re: Compile error user defined type not defined

    It's two ways to fix it:
    1. You have to turn on references to Microsoft Outlook Application.
    2. Or you have to use late binding e.g.
    Please Login or Register  to view this content.
    (*) Reputation points appreciated.
    excelbs.tk

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Compile error: User- defined type not defined
    By rolex in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2015, 05:08 PM
  2. Compile error: user defined type not defined
    By duhigs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-23-2014, 07:51 PM
  3. [SOLVED] Compile error: User-defined type not defined
    By XmisterIS in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-21-2014, 09:46 AM
  4. Error message: "Compile error. User-defined type not defined"
    By freckles81 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-13-2012, 09:37 AM
  5. compile error - user defined type not defined
    By TMP123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2010, 01:42 PM
  6. VB Compile Error - User-defined type not defined
    By dbwiz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-08-2010, 04:31 PM
  7. Error message: "Compile error. User-defined type not defined"
    By lottesfog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2007, 06:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1