Link to home
Start Free TrialLog in
Avatar of izakhar
izakhar

asked on

FileSave, FileSaveAs custom macros - are not triggered

I have to handle special procedures on File Save and File Save As event.
In order to do that I created FileSave and FileSaveAs macros (as suggested by manual)
For some reason those events are not triggered by save and save as action.
At the same time FilePrint and FilePrintDefault macros are startded with print action.
Any reason why FileSave is not starting?
Avatar of Joanne M. Orzech
Joanne M. Orzech
Flag of United States of America image

What is the name of your macro?  And where is it stored?  It should be in normal.dot and read:

Sub FileSave()
   'run macro here
    Dialogs(wdDialogFileSave).Show
End Sub

or

Sub FileSaveAs()
    'run macro here
    Dialogs(wdDialogFileSaveAs).Show
End Sub




Avatar of izakhar
izakhar

ASKER

I'm using custom global template macros.dot
It handles all code.

SaveAs starts if placed in Normal.dot
It doesn't work is placed in macros.dot

but

FileNew, FilePrint are working in macros.dot
Is your template stored in the proper startup folder?  If your template is named macros.dot - try this code:

Sub FileSaveAs()
    Application.Run ("FileSaveAs")
    Dialogs(wdDialogFileSaveAs).Show
End Sub

See if that works.

Here's how to run a macro from another template:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/off2000/html/womthRun.asp
Avatar of izakhar

ASKER

You know,
the problem is it never goes to Sub FileSaveAs()

yes, my template is stored in proper startup folder. It has hundreds procedures  and everything is working. It has custom macros for build in function (like FileNew) and those are working either.

The only problem is with FileSave and FileSaveAs.

Anyway, thank you very much for your answers!!!
Sorry - My code was wrong:

Sub FileSaveAs()
   'run your code here
    Application.Run MacroName:="macros.dot.NewMacros.FileSaveAs"  ' You may need to change the module or template name here
    Dialogs(wdDialogFileSaveAs).Show
End Sub

Avatar of izakhar

ASKER

Yes, I can set reference to that procedure from normal.dot, but I would like to keep normal.dot clean of any code

Sorry, it looks for me as corruption of world (I did already reinstall).
I'm going to check how it is working on other computer.
ASKER CERTIFIED SOLUTION
Avatar of Joanne M. Orzech
Joanne M. Orzech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of izakhar

ASKER

I found what problem is.

We have got conflict between macros.

There are a bunch of global templates in start up folder developed by 3rd party (those project are protected from viewing - this is only excuse for me). One of that macro has 3 procedures in it: FileOpen, FileSave, FileSaveAs.
Only one appearance of procedure with name assigned to MS World built in command is allowed for all templates located in start up folder.

Otherwise only one procedure will be executed and all other with the same name will be ignored.

The reason why procedures in my macro are ignored and in other template are executed is in template name. MS Word is looking in alphabetical order, i.e. aaa.dot.FileSave comes before bbb.dot.FileSave. (The highest priority has Normal.dot and after that all other templates in alphabetical order).

Sorry, you could not figure that out because you did not have complete picture.

Thanks!
In any event, I am very glad you got it resolved izakhar.