Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

VBA: Von Outlook aus eine Excel-Tabelle öffnen und auslesen

Empfohlene Antworten

Veröffentlicht

Hallo Leute,

ich möchte folgendes machen:

Über VBA (In Outlook) eine Excel-Tabelle öffnen (kann alternativ auch CSV sein), die erste Zelle auslesen und den Wert dieser Zelle in eine Mail mit einbinden. Leider habe ich noch absolut keine Erfahrung in VBA. ICh habe folgendes versucht - vielleicht kann mir ja jemand weiterhelfen...

Sub Mail_senden()

    Dim xlObj As Object

    On Error Resume Next

    Set xlObj = GetObject(, "Excel.Application")    'Get or open excel application

    If Err.Number <> 0 Then

        Err.Clear

        Set xlObj = CreateObject("Excel.Application")

    End If

    Set xlObj = xlObj.Workbooks.Open("d:\ex1.xlsx")

    xlObj.Activate

    Name = xlObj.cells(1, 1)


    Dim olApp As Object

    Dim Name As String

    Set olApp = CreateObject("Outlook.Application")

    With olApp.CreateItem(0)

        'Empfänger

        .Recipients.Add "name@bla.com"

        'Betreff

        .Subject = "Test-Mail"

        'Nachricht

        .Body = "Hallo " & Name & Chr(13) & _

                "Viele Grüße..." & Chr(13) & Chr(13)

        'Lesebestätigung aus

        .ReadReceiptRequested = False

        'Dateianhang

        '.Attachments.Add "c:\Dok1.doc"

        .Send

    End With

    Set olApp = Nothing

End Sub

Vielen Dank für eure Hilfe,

13lackAngle

also habs doch noch hinbekommen:


    Dim oExcel As Object


    Dim dateiname As String

    dateiname = "d:\ex2.xlsx"


    Dim row As Integer

    Dim column As Integer


    Dim anrede As String


    row = 1

    column = 1


    On Error Resume Next

    Set oExcel = GetObject(, "Excel.Application")    'Get or open excel application

    If Err.Number <> 0 Then

        Err.Clear

        Set oExcel = CreateObject("Excel.Application")

    End If


    oExcel.workbooks.Open FileName:=dateiname

    anrede = oExcel.cells(row, column)


    'MsgBox (oExcel.ActiveWorkbook.cells(1, 1).Value)

    'oExcel.workbooks("c:\1.xlsx").Close savechanges:=True

    oExcel.Quit

    'Workbooks("d:\ex1.xlsx").Close False  '(False speichert nicht, True speichert)


    Dim oMail As Object

    Dim Name As String

    Set oMail = CreateObject("Outlook.Application")

    With oMail.CreateItem(0)

        'Empfänger

        .Recipients.Add "darja.ferber@hp.com"

        'Betreff

        .Subject = "Test-Mail"

        'Nachricht

        .Body = "Hallo " & anrede & Chr(13) & _

                "Viele Grüße..." & Chr(13) & Chr(13)

        'Lesebestätigung aus

        .ReadReceiptRequested = False

        'Dateianhang

        '.Attachments.Add "c:\Dok1.doc"

        .Send

    End With

    Set oMail = Nothing

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.