Code not available when word template opened

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
Hi,

I've created a word form that has various buttons available depending on who opens it but now that I have saved it as a template I'm running into problems.

When the original word documnet was opened it had a "Private Sub Document_Open()" event procedure which displays an command button to e-mail the document or one to save and log the details in an Excel file depending on whether one of the members of my team opens the file or not.

Once saved and opened as a template I have had to change the procedure to a "Private Sub Document_New()" event procedure to sort the display of the buttons out which works fine but the problem that I have is that the code associated with the command buttons is not available in the new document and also additional code stored in modules are missing when the new document is created.

When I click on the command buttons in the new document I get an error: Run-time error '4248': This command is not available because no document is open.

I'm still a complete novice at Word VBA so any thoughts as to how I can get around this would be appreciated.

Dom
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Forget this (if you already hadn't) the whole having a button for the file to e-mail itself was just causing too many problems so have abandoned it.

Dom
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,697
Members
449,117
Latest member
Aaagu

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
Back
Top