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 3489994
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:27:45+00:00 2026-05-18T11:27:45+00:00

I am tring to create a macro (in Excel) to open another excel worksheet,

  • 0

I am tring to create a macro (in Excel) to open another excel worksheet, do a find-replace, then save it.

I have already achieved this with a word document like this:

...
Dim wrdDoc As Word.Document
If wrdApp Is Nothing Then Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open(TemplateFilePath)
...

Call WordReplace(wrdDoc,"a","b")

....

Private Sub WordReplace(wrdDoc As Word.Document, sFind As String, sReplace As String)
  With wrdDoc.Content.Find
    .Text = sFind
    .Replacement.Text = sReplace
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
  End With
End Sub

I have crudely tried to replace the word “Word” with “Excel” in the above code to no avail.

Can somone point me in the right direction please?

  • 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-05-18T11:27:45+00:00Added an answer on May 18, 2026 at 11:27 am

    You could do:

    Sub a()
    
    Dim excDoc As Workbook
    ....
    
    Set excDoc = Workbooks.Open("c:\mata.xls")
    Call WordReplace(excDoc, "a", "b")
    ....
    End Sub
    
    Private Sub WordReplace(excDoc As Variant, sFind As String, sReplace As String)
    
    Dim sht As Worksheet
    
    For Each sht In excDoc.Worksheets
      With sht
           .Cells.Replace What:=sFind, Replacement:=sReplace, LookAt:=xlWhole, _
            SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
            ReplaceFormat:=False
      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

I have an excel 2007 worksheet open with 5 colums and +/-5000 rows of
I am trying to create a Macro that either runs on close or on
I have 12 .csv files produced by another program. The .csv files contain numeric
I have a spreadsheet in Excel that connects to an internal DB using the
This is probably a basic question, but I have been having a hard time
I have successfully done this before but now after running the program numerous times
I am trying to create a macro for deleting the last char of a
I'm trying to create a simple macro using varargs, but I'm getting va_start used
I have a manual list I created in a macro in stata, something like
I am trying create a WCF service that leverages the WPF MediaPlayer on the

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.