![]() |
#1
|
|||
|
|||
![]()
Hello I am attempting to create a macro and add it to the normal.dotm so when I open any file that contains "contract" in the name and is an RTF file type it will prompt to run a macro and automatically find and replace specific text.
I have created the macro that finds and replaces the text. However i cannot get the file to prompt automatically upon opening. I also think i don't have the proper syntax to only run the file if it is an RTF file which contains the name contract. I have tried changing Document_Open() to AutoOpen, AutoExec but it still does not work. I enabled all macros in security settings as well. I am still relatively new to writing macros. Any help would be appreciated. Code:
Private Sub Document_Open() Call foodandbeveragemacro End Sub Sub foodandbeveragemacro() If Not Activedocument.Name "*contract*.rtf" Then Exit Sub Dim run As Variant run = MsgBox("Do you wish to remove gratuity detail from F&B clause. Canadian Properties only.", vbYesNo, "Canadian F&B Clause Change") If run = vbYes Then "remaining code left out as it runs fine" Last edited by macropod; 11-30-2013 at 02:46 PM. Reason: Added code tags |
Tags |
macros don't work, macros in word, vba word |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
casaserves | Word | 4 | 08-03-2013 01:11 AM |
![]() |
ximpostor | Word VBA | 10 | 10-12-2012 12:35 PM |
![]() |
netchie | Word VBA | 6 | 08-28-2012 03:37 PM |
can I run a macro when I open a specific doc. | shreked | Word | 8 | 01-12-2012 03:36 AM |
Getting COMException Incompatible file type and file extension | sbalerao | Mail Merge | 0 | 04-21-2011 10:30 AM |