Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

über Excel in word suchen

1 view
Skip to first unread message

manfred

unread,
Aug 28, 2009, 9:08:49 AM8/28/09
to
Hallo Leute ich hoffe es kann mir wer helfen.
ich m�chte einen text "Test" suchen und dann alles nach oben markieren, um
die anzahl der markierten Tabellen zu bekommen.

jetzt hab ich aber das Problem in word funktioniert es und in Excel st�rst
es mir komplett ab. =(

bitte um hilfe.

Danke

Manfred

Word.Selection.Find.ClearFormatting
With Word.Selection.Find
.Text = "Test"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Word.Selection.Find.Execute
Word.Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
t = Word.Selection.Tables.Count


Andreas Killer

unread,
Aug 28, 2009, 11:28:25 AM8/28/09
to
manfred schrieb:

> jetzt hab ich aber das Problem in word funktioniert es und in Excel stᅵrst

> es mir komplett ab. =(

Ist recht einfach, Excel kennt die Konstanten nicht die Word kennt und
auᅵerdem weiᅵ ich nicht wie Du die Word-Instanz initialisierst. Daher
bitte das nᅵchste Mal das komplette Makro posten.

Der Code-Schnipsel lᅵuft so ohne Problem.

BTW, heiᅵer Tip bei solchen Aktionen: Immer "Option Explicit" oben
drᅵber schreiben!

Andreas.

Option Explicit

Const wdFindContinue = 1
Const wdStory = 6
Const wdExtend = 1

Sub test()
Dim Word As Object, T As Long
Set Word = GetObject(, "Word.Application")

Word.Selection.Find.ClearFormatting
With Word.Selection.Find
.Text = "Test"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Word.Selection.Find.Execute
Word.Selection.HomeKey Unit:=wdStory, Extend:=wdExtend

T = Word.Selection.Tables.Count
End Sub

0 new messages