sandam
03-01-2005, 04:04 AM
Hi all. I have suddenly ventured into the complicated side of macro writing and I've come undone.
Here's the story.
we have a back office system that does the following. It allows you to create headers (templates) and regular documents (.doc's). You can attach a header to a document or not. But bascially you take these two documents with merge fields that insert database data.
The process is:
1. Create new document from header
2. Insert other document (Insert->File)
3. Mail Merge this combination into a new document
4. Run macros from a global template on the new document to do word processing requirements.
These macros are basically;
1. Create toolbar to access macros for document.(thanks again to everyone at VBAX who showed me how)
2. Automatically run the starting macro after toolbar has been created to complete the reqired part of the document. (inserting address and other details)
3. Run a print macro when the toolbar button is clicked (each document is printed differently hence the need)
My problems are this:
1. I can work on multiple different documents using te same global template but only after each document has run through its specific macro Eg a letter, a memo and a fax cover sheet. Each ahs there own macro to run post merge. They all work fine but each macro has to be completed before the next doc can be created. Is there a way around this? or is it that each macro has to finish and unload its references to the global template before the next one runs?
2. It seems that everyother document post merge sequence does not load the global template and its macros. How do I ensure that the document has these references regardless of the number of times the global template is invoked?
3. A side issue I have tried to deal with is getting focus to the document post merge sequence. sometimes it happens sometimes it doesn't. this is what I have tried for this
Sub NewBlankDocument()
CreateToolbar ("New Blank Document") 'This creates a toolbar specific to the doc
ActiveDocument.ActiveWindow.WindowState = wdWindowStateMaximize
ActiveDocument.ActiveWindow.SetFocus
StartBlankDocMacro 'this runs the macro associated with the document
End Sub
apologies - as usual i forget to put in what matters even more than the problem. My entire firm operates on Office 2003 SP1 and windows xp prof SP1
Here's the story.
we have a back office system that does the following. It allows you to create headers (templates) and regular documents (.doc's). You can attach a header to a document or not. But bascially you take these two documents with merge fields that insert database data.
The process is:
1. Create new document from header
2. Insert other document (Insert->File)
3. Mail Merge this combination into a new document
4. Run macros from a global template on the new document to do word processing requirements.
These macros are basically;
1. Create toolbar to access macros for document.(thanks again to everyone at VBAX who showed me how)
2. Automatically run the starting macro after toolbar has been created to complete the reqired part of the document. (inserting address and other details)
3. Run a print macro when the toolbar button is clicked (each document is printed differently hence the need)
My problems are this:
1. I can work on multiple different documents using te same global template but only after each document has run through its specific macro Eg a letter, a memo and a fax cover sheet. Each ahs there own macro to run post merge. They all work fine but each macro has to be completed before the next doc can be created. Is there a way around this? or is it that each macro has to finish and unload its references to the global template before the next one runs?
2. It seems that everyother document post merge sequence does not load the global template and its macros. How do I ensure that the document has these references regardless of the number of times the global template is invoked?
3. A side issue I have tried to deal with is getting focus to the document post merge sequence. sometimes it happens sometimes it doesn't. this is what I have tried for this
Sub NewBlankDocument()
CreateToolbar ("New Blank Document") 'This creates a toolbar specific to the doc
ActiveDocument.ActiveWindow.WindowState = wdWindowStateMaximize
ActiveDocument.ActiveWindow.SetFocus
StartBlankDocMacro 'this runs the macro associated with the document
End Sub
apologies - as usual i forget to put in what matters even more than the problem. My entire firm operates on Office 2003 SP1 and windows xp prof SP1