Macro associated with template

EMH

New Member
Joined
Jul 3, 2011
Messages
9
Hi there,

Sorry if this is another really basic question, but I really appreciated the help I got last time and just need to know: I am creating a macro enabled template in Word 2010 for someone. I have some really basic macros e.g. inserting an autotext (as the end user is more familiar with macros than autotexts). When I look at the code, it references where the template is saved i.e. my C drive. If I email this template it still points to this location, and therefore won't run (run time error 5941 - the requested member of the collection does not exist). Do I just take out everything except the template name or do I need to add something else?

Code:
Application.Templates( _
         "C:\Documents and Settings\2011\!  Work\Note_Template Final.dotm" _
        ).BuildingBlockEntries("Chart Narrow").Insert Where:=Selection.Range, _
        RichText:=True
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
If there's the slightest possibility your Word document, Excel workbook or Access database might move its location, it's considered good practice to make any code independent of location, i.e. don't hard code folder paths unless there's a good reason for doing so.

ThisDocument.FullName tells you what your document is called and where it was loaded from.

There are also methods for fetching the true paths of system folders like My Documents, the user's TEMP directory, his Desktop, etc, if this is necessary.
<!-- / message --><!-- sig -->
 
Last edited:
Upvote 0
Thanks for this - it gives me the lead I need. I am logging off now as it's 1am - if I need further help I'll come back tomorrow! :)
 
Upvote 0

Forum statistics

Threads
1,224,581
Messages
6,179,668
Members
452,936
Latest member
anamikabhargaw

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