WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Userform for Macro "Find & Replace in all Documents"

 
Goto page Previous  1, 2
   Home -> Office -> User Forms RSS
Next:  Word document surveys in table format  
Author Message
shabutt

External


Since: Jun 24, 2008
Posts: 12



(Msg. 9) Posted: Wed Jul 09, 2008 4:21 am
Post subject: Re: Userform for Macro "Find & Replace in all Documents" [Login to view extended thread Info.]
Archived from groups: microsoft>public>word>vba>userforms (more info?)

Dear Mr. fumei,

Thank you for your excellent help. Your macro is a beauty.

I didn't need a userform to do what I wanted. But we are lucky to have
helpful MVPs and their endless solutions. Needless to say I got more than
what I bargained for. Smile

Regards

"fumei via OfficeKB.com" wrote:

> I would have to agree about being very explicit, and clear, when you ask
> things.
>
> Here is a possible alternative to making a userform, although if you actually
> want a Clear (although...why exactly?) button.
>
> Do you know how to put a button on a toolbar? That may be the easiest. What
> I mean is, HOW do you actually want to call the code below? You could, as I
> said, put it as a button on a toolbar, then you can just click it and the
> code runs. Or, you could have it as a keyboard shortcut.
>
> In any case, if the issue is - and again, please be clear about what IS the
> issue - simply an easy way to get a string (a word, or a phrase) that you
> want to find, and a string (a word or phrase) to replace it with:
>
>
> Sub FRinallDoc()
> Dim aDoc As Document
> Dim r As Range
> Dim myFind As String
> Dim myReplace As String
>
> myFind = Inputbox(“Enter text to find.”)
> myReplace = Inputbox(“Enter replacement text.”)
>
> For Each aDoc In Application.Documents
> Set r = aDoc.Range
> With r.Find
> .Text = myFind
> .Replacement.Text = myReplace
> .Execute Replace:=wdReplaceAll
> End With
> Next
> End Sub
>
> This displays an inputbox for the Find string, an inputbox for the Replace
> string...and goes and does it.
>
> Now if you want to be able to do multiple operations, then yes, absolutely, a
> userform would be best. Again though, you need something to call, to display
> (Show) the userform. This code can be attached to a button on the toolbar, a
> menu item, or a keyboard shortcut.
>
> Jean-Guy Marcil wrote:
> >> Dear Mr. Robbins,
> >>
> >> I did what you instructed me to do but was unable to run the userform.
> >
> >Why? What did you try exactly?
> >Vague statements of helplessness make it difficult to provide accurate and
> >useful replies.
> >It is always a good idea to take the few more minutes it takes to describe
> >what was attempted, the expected results and the observed results.
> >
> >Meanwhile, try this:
> >In a standard module, use code like this:
> >(Assuming that your userform is named "UserForm1" and that one of the
> >buttons contains the code Doug Posted.)
> >
> >Dim myForm As UserForm1
> >
> >Set myForm = New UserForm1
> >
> >myForm.Show
> >
> >Unload myForm
> >
> >Set myForm = Nothing
> >
> >If you want to keep the userform on the screen to do many consecutive Find/
> >Replace, use the code I suggest above and modify Doug's code like this:
> >
> >Use Doug's code for a button called "Repalce" but remove the
> > Me.Hide
> >statement from the code.
> >
> >Create an "Exit" button with the code:
> > Me.Hide
> >
> >If you want a "Clear" button use this code for this third button
> >
> >With Me
> > .txtFind.Text = ""
> > .txtReplacement.Text = ""
> > .txtFind.SetFocus
> >End With
>
> --
> Message posted via http://www.officekb.com
>
>
Back to top
Login to vote
Jean-Guy Marcil

External


Since: Feb 18, 2008
Posts: 344



(Msg. 10) Posted: Wed Jul 09, 2008 6:49 am
Post subject: Re: Userform for Macro "Find & Replace in all Documents" [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"shabutt" wrote:

> Dear Mr. Marcil (MVP),
>
> Thank you very much for the code and detailed explanation as well. I am able
> to run the macro successfully. It is wonderful to have a lot of options in
> the userform and this is only possible due to your guidance.

You are welcome!

> Here is the userform code which has four buttons namely OK (for single Find
> & Replace), REPLACE (for multiple Find & Replace ), CLEAR (for clearing the
> textboxes), & CANCEL (for exiting/closing).
>

This 4-button set-up requires you to do two clicks if you want to do
multiple find/replace actions.

I would remove the CLEAR button and include that code at the end of the
REPLACE button's code. This way, when you do a replace knowing you will do
another one after that, the textboxes will be automatically cleared...
Back to top
Login to vote
shabutt

External


Since: Jun 24, 2008
Posts: 12



(Msg. 11) Posted: Wed Jul 09, 2008 9:06 pm
Post subject: Re: Userform for Macro "Find & Replace in all Documents" [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Jean-Guy Marcil" wrote:

> I would remove the CLEAR button and include that code at the end of the
> REPLACE button's code. This way, when you do a replace knowing you will do
> another one after that, the textboxes will be automatically cleared...

That is icing on the top. Thank you very much.
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> User Forms All times are: Eastern Time (US & Canada) (change)
Goto page Previous  1, 2
Page 2 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
 WinRAR
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET