Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-23-2023, 02:19 AM
Profti Profti is offline Windows 10 Office 2016
Novice
 
Join Date: Oct 2023
Posts: 7
Profti is on a distinguished road
Default Probleme beim Zugriff auf eingefügtes Dropdownfeld

Hallo zusammen,


bin etwas neu in VBA, soll aber in der Ausbildung ein Script schreiben, welches beim drücken auf einen Button den ausgewählten Wert aus einem Dropdownfeld nimmt und in eine Email pakt. Das Dropdownfeld wird aber mittels einem Vorlagensystem "Docunize" eingefügt. Das folgende Script nutzt aber immer den voreingestellten Wert und nicht den aktuell ausgewöhlten Wert. Hat jemand Ideen?


Code:
Sub cmdVersenden_Click()


   Dim comboBox As ContentControl
   Dim wert As String
   Set comboBox =         ThisDocument.SelectContentControlsByTitle("PersonalNumber")(1)

     If Not comboBox Is Nothing Then
        If comboBox.Type = wdContentControlComboBox Then
             wert = comboBox.Value
            MsgBox "Der Inhalt des Dropdown-Felds wurde in die Variable kopiert: " & wert
        Else
            MsgBox "Das ausgewählte Formularfeld ist kein ComboBox-Feld."
        End If
    Else
        MsgBox "Das ComboBox-Formularfeld wurde nicht gefunden."
    End If


    Dim OutlookApp As Object
    Dim OutlookMail As Object
    
    Set OutlookApp = CreateObject("Outlook.Application")
    
    Set OutlookMail = OutlookApp.CreateItem(0)
    
    TmpDOC = FindTemp() & "Dokument_Betrieb.doc"
    
    ActiveDocument.SaveAs FileName:=TmpDOC, FileFormat:=wdFormatDocument, _
    LockComments:=False, Password:="", AddToRecentFiles:=True, _
    WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, SaveFormsData:=False,    SaveAsAOCELetter:=False
    
    
    With OutlookMail
        .Subject = "Dokument- Betriebs-Personal - " & wert
        .To = "interne.Email@Betrieb.de"
        .Body = "Sehr geehrte Damen und Herren," & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "anbei ein Dokument vom Betrieb" & Chr(13) & Chr(10) & Chr(13) & Chr(10)
        .Attachments.Add TmpDOC                     ' Dokument als Anhang anfügen
        .Display                                    ' E-Mail anzeigen (nicht senden)
    End With
End Sub

Wäre für hilfreiche Antworten Dankbar.
PS: ChatGPT gibt auch nichts funktionierendes raus

MFG


Timo
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
outlook löscht beim Abruf gemeinsamer imap Emalemail auf dem server kleinermax Outlook 0 12-20-2019 04:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft