Thema Datum  Von Nutzer Rating
Antwort
02.04.2020 12:11:02 Estelle
*****
NotSolved
03.04.2020 16:41:23 Gast14621
NotSolved
06.04.2020 12:48:19 Gast31315
NotSolved
Blau Formatierung in Textmarken mit VBA übernehmen
06.04.2020 22:48:44 Gast14621
NotSolved
06.04.2020 22:56:54 Gast14621
NotSolved
07.04.2020 09:56:16 Gast25041
NotSolved
07.04.2020 13:06:31 Gast95775
NotSolved
07.04.2020 15:03:38 Gast64055
NotSolved
07.04.2020 16:56:55 Gast55674
NotSolved
08.04.2020 17:12:03 Gast3733
NotSolved
09.04.2020 18:07:16 Gast45089
NotSolved
10.04.2020 19:44:14 Gast14621
NotSolved

Ansicht des Beitrags:
Von:
Gast14621
Datum:
06.04.2020 22:48:44
Views:
778
Rating: Antwort:
  Ja
Thema:
Formatierung in Textmarken mit VBA übernehmen

Hallo,

oh ja, teufel, da hab ich ein Font-Objekt übersehen, hab dafür nochmal ein paar Eig. drangehängt, so müsste es was werden...

 

Option Explicit

Private Sub CommandButton1_Click()
   Dim oExcelApp As Object
   Dim oExcelWorkbook As Object
   Dim lZeile As Long
   Dim objRange As Range
   If ListBox1.ListIndex >= 0 Then
      
         Set oExcelApp = CreateObject("Excel.Application")
         Set oExcelWorkbook = oExcelApp.Workbooks.Open(sBeispiel)
      
         lZeile = 2
         With oExcelWorkbook.Sheets(sTabellenblatt)
                Do While .Cells(lZeile, 1) <> ""
                    If ListBox1.Text = CStr(.Cells(lZeile, 2).Value) Then
                        Set objRange = ActiveDocument.Bookmarks("Textmarke_Name ").Range
                        With .Cells(lZeile, 2)
                            objRange.Text = CStr(.Value)
                            Call Font_Transfer(probjWdFont:=objRange.Font, probjXlFont:=.Font)
                        End With
                        Set objRange = ActiveDocument.Bookmarks("Textmarke_ID").Range
                        With .Cells(lZeile, 1)
                            objRange.Text = CStr(.Value)
                            Call Font_Transfer(probjWdFont:=objRange.Font, probjXlFont:=.Font)
                        End With
                        Set objRange = ActiveDocument.Bookmarks("Textmarke_Beschreibung").Range
                        With .Cells(lZeile, 3)
                            objRange.Text = CStr(.Value)
                            Call Font_Transfer(probjWdFont:=objRange.Font, probjXlFont:=.Font)
                        End With
                        Set objRange = Nothing
                        Exit Do
                    End If
                    lZeile = lZeile + 1
                Loop
         End With
         
         oExcelWorkbook.Close False
         oExcelApp.Quit
      
     Else
         MsgBox "Bitte wählen Sie einen Eintrag aus der Liste aus!", _
             vbInformation + vbOKOnly, "HINWEIS!"
         Exit Sub
     End If
 
    Set oExcelWorkbook = Nothing
    Set oExcelApp = Nothing
    Unload Me
End Sub

Private Sub Font_Transfer(ByRef probjWdFont As Font, ByRef probjXlFont As Object)
With probjXlFont
     probjWdFont.Color = .Color
     probjWdFont.Bold = .Bold
     probjWdFont.Name = .Name
     probjWdFont.Italic = .Italic
     probjWdFont.Underline = GetFontUnderline(pvlngXlUnderline:=.Underline)
End With
End Sub

Private Function GetFontUnderline(ByVal pvlngXlUnderline As Long) As WdUnderline
   Const xlUnderlineStyleNone As Long = -4142
   Const xlUnderlineStyleSingle As Long = 2
   Const xlUnderlineStyleDouble As Long = -4119
   Select Case pvlngXlUnderline
      Case Is = xlUnderlineStyleNone: GetFontUnderline = wdUnderlineNone
      Case Is = xlUnderlineStyleSingle: GetFontUnderline = wdUnderlineSingle
      Case Is = xlUnderlineStyleDouble: GetFontUnderline = wdUnderlineDouble
   End Select
End Function

Gruß,


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
02.04.2020 12:11:02 Estelle
*****
NotSolved
03.04.2020 16:41:23 Gast14621
NotSolved
06.04.2020 12:48:19 Gast31315
NotSolved
Blau Formatierung in Textmarken mit VBA übernehmen
06.04.2020 22:48:44 Gast14621
NotSolved
06.04.2020 22:56:54 Gast14621
NotSolved
07.04.2020 09:56:16 Gast25041
NotSolved
07.04.2020 13:06:31 Gast95775
NotSolved
07.04.2020 15:03:38 Gast64055
NotSolved
07.04.2020 16:56:55 Gast55674
NotSolved
08.04.2020 17:12:03 Gast3733
NotSolved
09.04.2020 18:07:16 Gast45089
NotSolved
10.04.2020 19:44:14 Gast14621
NotSolved