Anyone any ideas about Word macros?

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
Hi Domski,

Running a macro in Word is just like in Excel. Tools > Macro > Macros.

The macro can also be assigned to a button, in the same way you would do it in Excel.

One thing you need to watch out for when adding the macro to a Word document. It is quite easy to accidentally place the macro in the Normal template rather than in the document. This is fine if you want the macro to be available in every Word document. But if the macro is unique to the document you are editing, in the Visual Basic Editor, be sure that you add the new macro module to the Project (DocumentX) project.

Damon
 

Macropod

Retired Moderator
Joined
Aug 27, 2007
Messages
3,514
Hi,

The code you're referring to is apparently meant to be run from a userform named 'QueryForm' - you can see that from the CloseBtn_Click sub. It seems that form has at least 3 buttons: CloseBtn, FindBtn and ReplaceBtn.

Without the form and those buttons, you could get the code to run by deleting the word 'Private' from these two subs:
Code:
Private Sub FindBtn_Click()
' just find, no replace
Call DoReplace(wdReplaceNone)
End Sub

Private Sub ReplaceBtn_Click()
' replace it
Call DoReplace(wdReplaceAll)
End Sub
then selecting either macro in the normal way.

Cheers
 

Watch MrExcel Video

Forum statistics

Threads
1,123,158
Messages
5,600,054
Members
414,357
Latest member
Gemma_R

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top