A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Excel -> Word (Textbox Find/Replace)



 
 
Thread Tools Display Modes
  #1  
Old July 7th 12, 09:51 AM
aiwnjoo aiwnjoo is offline
Junior Member
 
First recorded activity by ExcelBanter: Jul 2012
Posts: 1
Thumbs up Excel -> Word (Textbox Find/Replace)

Hi guys, really struggling here and tried on different forums but nobody seems equipped to resolve this so fingers crossed that there is a genius amongst us

Current Macro, this is fully working for non-textbox find/replace however i need a version of this that supports textboxes.

Code:
Sub Replacing()


    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Application.Cursor = xlWait
    Application.DisplayStatusBar = True
    Application.StatusBar = "Generating DM Pack, please wait!"
    
    On Error GoTo 0
    
    Dim sFile     As String
    Dim wrdApp    As Word.Application
    Dim wrdDoc    As Word.Document
    Dim sInput(0) As String, sOutput(0) As String


    sFile = "KF"
    
    Set wrdApp = New Word.Application


    With wrdApp
    
        .Visible = True
        
    Set wrdDoc = .Documents.Open("C:\Docs\" + sFile + ".doc")
    
    .Selection.Find.ClearFormatting
    .Selection.Find.Replacement.ClearFormatting
    
    sInput(0) = "Test"
    
    sOutput(0) = "ACCREF"
    
    
    For i = 0 To UBound(sInput) - 1
    
      With .Selection.Find
        .Text = sOutput(i)
        .Replacement.Text = Range(sInput(i)).Text
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute Replace:=wdReplaceAll
        
    End With
    
    Next
Thanks,
Ads
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel wait for Find Replace dialog box in Word JasonC Excel Programming 4 May 24th 10 09:34 PM
Find and replace in Word from Excel gab1972 Excel Programming 2 October 5th 09 11:36 PM
Find/Replace macro from excel to word Matt[_40_] Excel Programming 4 August 1st 06 03:43 AM
Find/Replace macro from excel into Word Matt[_40_] Excel Programming 0 July 28th 06 04:37 PM
How can I use find and replace to delete a word in Excel? callpaultwt Excel Discussion (Misc queries) 2 December 1st 05 09:11 PM


All times are GMT +1. The time now is 05:29 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2004-2013 ExcelBanter.
The comments are property of their posters.