Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8997235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:51:39+00:00 2026-06-15T23:51:39+00:00

There is simple VBA macros for Excel (2003). It look to cell A$N and

  • 0

There is simple VBA macros for Excel (2003). It look to cell A$N and B$N, and replace in Word document text from B$N to A$N.

Sub Макрос1()

Dim pathh As String, i As Integer
pathh = "c:\1.doc"
Dim pathhi As String
Dim from_text As String, to_text As String
Dim WA As Object, WD As Object
Set WA = CreateObject("Word.Application")
WA.Documents.Open (pathh)
WA.Visible = True

For oCell = 1 To 150
    from_text = Range("B" + CStr(oCell)).Value
    to_text = Range("A" + CStr(oCell)).Value
    With WA
        .Activate
        With .Selection.Find
          .ClearFormatting
          .Replacement.ClearFormatting

          .Text = from_text
          .Replacement.Text = to_text
          .Execute Replace:=wdReplaceAll
        End With
    End With
Next
End Sub

Problem: in Word document this script only select text, but don’t make replacement. Nay suggestion?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:51:40+00:00Added an answer on June 15, 2026 at 11:51 pm

    First I expect you to have the reference to the Word object library active:
    Reference to Word

    The the script whould actually work, I made some minor modifications and have this working including replace:

    Sub test1()
    
        Dim pathh As String
        Dim pathhi As String
        Dim oCell  As Integer
        Dim from_text As String, to_text As String
        Dim WA As Object
    
        pathh = "C:\1.doc"
    
        Set WA = CreateObject("Word.Application")
        WA.Documents.Open (pathh)
        WA.Visible = True
    
        For oCell = 1 To 2
            from_text = Sheet2.Range("B" & oCell).Value
            to_text = Sheet2.Range("A" & oCell).Value
            With WA
                .Activate
                With .Selection.Find
                  .ClearFormatting
                  .Replacement.ClearFormatting
    
                  .Text = from_text
                  .Replacement.Text = to_text
                  .Execute Replace:=wdReplaceAll
                End With
            End With
        Next
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a simple way to reduce the Font Size in Word / Excel
I have a fairly simple bit of VBA in Word 2003 that changes the
There seem to be a bunch of things in the Word 2007/2010 VBA object
I have multiple MS-Access 2003 project with some VBA code and there are some
I'm currently building a VBA based application on Microsoft Excel. I used simple activeX
Are there something like pointers in VBA? I'm trying to make an excel macro,
In my Excel sheet, I have VBA code to detect the last non-empty cell
Are there simple libraries out there (.NET and Java) that are able to validate
There is simple cipher that translates number to series of . ( ) In
There is simple JSON serialization module with name simplejson which easily serializes Python objects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.