Z
Z
Zulkund2016-03-30 08:11:53
Macros
Zulkund, 2016-03-30 08:11:53

Help me write VBA code for MS OFFICE?

Gentlemen, help me solve the following problem. We need a macro that would find the desired line in the word file, for example "@here" and insert the contents from the buffer here. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TomasHuk, 2016-03-30
@Zulkund

Seems to work:

Sub Replace()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "@here"
        .Replacement.Text = "^c"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question