Discussion Locked

Macro Installation from VB

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am writing a small utility in VB, which has to handle Word documents.
Now the specific problem I come across is that I need to also write a bit of macro in word's all the created templates also.
Can I write these macros in VB itself and install it in word's template through VB itself? If so, please let me know how.

Thanks in advance
Mahesh

7 replies

by glen_mcleod

I had a quick look and couldn't find anything about adding macros through VB. But what you could do is take your macro code, compile it into a DLL (you can do this from within Word's VB Editor), and add a reference to the DLL as an add-in to the templates.

It's a little more involved than this, but since you're using Word's object model anyway, you can manipulate the add-ins as well.

Glen

by eddie c

Yes, you can copy the macro into the blank document template. HOW?

Workaround:
1. Go to File>New
2. Select a blank document. And make sure that you open it as template. (You can see the radio button at the lower right corner.)
3. Now you paste the macro into the template.
4. When it is done, you need to save it as template using the same name. (Normal.dot)

Voila! I just tried it. It works on mine.

Good Luck!

Eddie
Microsoft Certified System Engineer

by maheshkumarvk

Hi Eddie,

Thanx. This works fine but the specific problem is that there are around 30 templates and an anticipation of more templates. I don't want to ask the users to copy and paste the code in each and every template.

Thanx anyway
Keep in touch.

by eddie c

If my previous suggestion does not apply, I think the following may help you out.

All the templates are saved under C:\Program Files\Microsoft Office\Templates folder.

After you updated the template files on your computers, you may save those dot files from that folder into a floppy disk. Now, you can just replace the template files on the workstation with the files on your floppy disk.

Voila! I am sure that it will save you lot of time, huh!

Good Luck again.

Eddie
Microsoft Certified System Engineer

by maheshkumarvk

Hi Eddie,

Thats great bu what if they come out with a new template. The client is an MT company and they create templates very often.
If it is an installation like kit that could select the template from the folder and write it into the template , then I think my problem is solved
Thanx a lot Eddie
Keep in touch.

This discussion is closed to new replies.