Hi Guys,
My problem is the following. The following code finds the text what I want, but I don't know how to copy it in excel cell.
Private Sub CommandButton1_Click() 'Teszt_2_1
Dim ws As Worksheet, msWord As Object
Set ws = ActiveSheet
Set msWord = CreateObject("Word.Application")
Dim a As Variant
For a = 2 To 3
With msWord
.Visible = True
.Documents.Open "C:\Users\mahlj01\Desktop\Egy嶵\Dokumentumkezelő\Excelek_v2\" & Range("A" & a) & ".doc"
.Activate
Dim b As Variant
For b = 2 To 2
With .ActiveDocument.Content.Find
.ClearFormatting
.Text = Worksheets("Teszt_2").Cells(b, 2).Value
With .Replacement
.ClearFormatting
.Font.Bold = True
.Font.Color = 65280 '12611584
.Text = Worksheets("Teszt_2").Cells(b, 2).Value
End With
.Replacement.Text = Worksheets("Teszt_2").Cells(b, 2).Value
.Forward = True
.Wrap = 1 'wdFindContinue (WdFindWrap Enumeration)
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=2 'wdReplaceAll (WdReplace Enumeration)
'While .Excute
If .Found = True Then
.Copy
Worksheets("Teszt_2").Cells(a, 3) =
End If
End With
Next b
.ActiveDocument.Save
.ActiveDocument.Close _
SaveChanges:=wdSaveChanges
End With
Next a
End Sub
Any idea?
Bookmarks