Thema Datum  Von Nutzer Rating
Antwort
18.11.2014 14:56:22 Mara
NotSolved
19.11.2014 10:37:06 Gast60144
Solved
20.11.2014 15:12:15 Gast58649
NotSolved
20.11.2014 19:59:39 Gast13621
NotSolved
24.11.2014 08:27:23 Mara
NotSolved
24.11.2014 08:40:15 Mara
NotSolved
24.11.2014 09:25:08 Gast92691
NotSolved
25.11.2014 07:17:57 Mara
NotSolved
03.12.2014 11:09:21 Mara
NotSolved
03.12.2014 11:25:21 Ambg
NotSolved
Rot Run-time error
03.12.2014 11:30:43 Gast96518
NotSolved
03.12.2014 14:50:36 Mara
NotSolved
03.12.2014 15:18:58 Ambg
NotSolved
09.12.2014 15:27:19 Mara
NotSolved
09.12.2014 20:11:17 Ambg
NotSolved
10.12.2014 15:31:23 Mara
NotSolved

Ansicht des Beitrags:
Von:
Gast96518
Datum:
03.12.2014 11:30:43
Views:
802
Rating: Antwort:
  Ja
Thema:
Run-time error

Hallo Ambg,

der Code ist genau der, den ich oben bekommen habe. Die Pfadangabe stimmt auf jeden Fall. Ich hatte vorhin einmal einen falschen Pfad eingegeben, da wurde jedoch auch expliziert ausgeworfen, dass der Pfad nicht korrekt ist.

Theoretisch ist nichts offen. Das verwirrt mich ja so *hmmm*

Vielen Dank!

 

Option Explicit
 
Sub Test()
'
' Vorgaben:
' aktive Excel-Tabelle
' [A1] - Pfad zum Word Dokument (hier: E:\Temp\Test.docx)
' [A2] - [Ax] Suchbegriffe
'******************************************************************************
'
Dim oExcelList As Object
Dim oExcelSheet As Excel.Worksheet
Dim c As Excel.Range
Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document
Dim wdr As Word.Range
Dim sText As String
Dim lCnt As Long, lFnd As Long
 
Set oExcelSheet = ThisWorkbook.ActiveSheet
Set c = oExcelSheet.Range("A1")
Set oExcelList = CreateObject("System.Collections.ArrayList")
 
   oExcelList.Add c.Text
   Set c = c.Offset(1)
   Do While c.Text <> vbNullString
      oExcelList.Add c.Text
      Set c = c.Offset(1)
   Loop
 
Set oWordApp = CreateObject("Word.Application")
Set oWordDoc = oWordApp.Documents.Open(oExcelList.Item(0))
 
With oWordDoc
   Set wdr = .Content
   For lCnt = 1 To oExcelList.Count - 1
      sText = oExcelList.Item(lCnt)
      lFnd = 0
      Do
         wdr.Find.Execute FindText:=sText, Forward:=True
         If Not wdr.Find.Found Then Exit Do
         With wdr
            .Bold = True
            .Font.ColorIndex = wdRed
         End With
         lFnd = lFnd + 1
         oExcelList.Item(lCnt) = sText & Format(lFnd, " #0 Ersetzungen")
      Loop
      Set wdr = .Content
   Next lCnt
End With
 
oWordDoc.Close
oWordApp.Quit
 
Call MsgBox(Join(oExcelList.toarray(), Chr(10)), vbInformation, "Geschafft!")
 
End Sub

 


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
18.11.2014 14:56:22 Mara
NotSolved
19.11.2014 10:37:06 Gast60144
Solved
20.11.2014 15:12:15 Gast58649
NotSolved
20.11.2014 19:59:39 Gast13621
NotSolved
24.11.2014 08:27:23 Mara
NotSolved
24.11.2014 08:40:15 Mara
NotSolved
24.11.2014 09:25:08 Gast92691
NotSolved
25.11.2014 07:17:57 Mara
NotSolved
03.12.2014 11:09:21 Mara
NotSolved
03.12.2014 11:25:21 Ambg
NotSolved
Rot Run-time error
03.12.2014 11:30:43 Gast96518
NotSolved
03.12.2014 14:50:36 Mara
NotSolved
03.12.2014 15:18:58 Ambg
NotSolved
09.12.2014 15:27:19 Mara
NotSolved
09.12.2014 20:11:17 Ambg
NotSolved
10.12.2014 15:31:23 Mara
NotSolved