Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WORD XP: template / vba : 2 questions

Status
Not open for further replies.

TravisLaborde

IS-IT--Management
Joined
Nov 4, 2002
Messages
84
Location
US
I am using Word XP to automate building certain rich documents used by our company. I have built a template document, which uses VBA to get data via RDS from our back end database, and populate the document accordingly. It works fine, but I have four questions regarding enhancements I'd like to make:

1) I have the document saved as a ".dot" file, and when the user opens it, it automatically creates "Document1" based on the template. However, when they save their new document, it still contains the VBA code. Is there a way to cause the save to be "only" the text and not the VBA? I'd like the code to reside in the template only.

2) Just as in #1 above, I'd like the newly saved document to not carry the properties of the template, such as being read only.

3) The VBA auto-runs when the document is opened, and prompts the user for an "account number." Is there a way to "command line" drive this instead? So, instead of entering account # "123" in a prompt, perhaps the document could be opened with command line arguments such as "msword.exe mydocument.dot 123" or something like that?

4) Is there a way to prevent the users from being able to view the VBA code? I know there are hacks out there for protected documents and such, but at least "some" protection would be nice.

Thanks!
Travis
 
1. Doesn't sound right. When you get Document1, is it a template or a document? Hit File-Save as. Does it want to save it as a template or a doc?

2. Ditto. Doesn't sound right.

3. I hope the VBA auto-runs on document_new, not document_open. Why have it auto-fill if it's always the same value? Why have the form pop up if you don't want to fill it in that way?

4. Sure. Alt+F11. Right-click the DOT name, and hit Properties. Put a password for viewing the project. And you're right-it's crackable, but not by the typical user. Anne Troy
Word and Excel Macros
Coming soon: wX
 
1) When I double-click on the ".dot" file, what opens in Word is "Document1.doc" which also wants to save as "document1.doc" when I hit Save-As.

2) see above..

3) When I added the VBA to a regular .doc file, it was in Document_Open. When I renamed the file to a .dot file, it didn't run, so I added code to the Document_New event, that simply calls Document_Open. This is wrong???

4) I don't see what you are talking about. When I hit Alt+F11, the VBA editor comes up, and I have Normal, Project(Document1), and Project(filename). I'm assuming you are referring to the third one, but I don't see which property you are referring to.

Thanks!
Travis
 
1 & 2. Better see your code and tell us where the code is stored (module or this doc)

3. Yep, that's correct, but your comments sounded like this must have been incorrect.

4. If you right-click Project (filename), you get a menu. Choose Properties.

:) Anne Troy
Word and Excel Macros
Coming soon: wX
 
1&2) The code is stored in This Document. (Referring I hope to the .dot file). When I save document1.doc, the code still resides in This Document...

3) huh? correct that I'm wrong, or correct that I'm not wrong? sorry :)

4) Got it! Thanks!

I really appreciate your help! Please don't get weary of my just yet, we're almost there!

Travis
 
1&2: Trying to find out.

3) Yes, you are correct. (Your comments made me question it.)

4. Cool.

Can I possibly see your dot?
Anne@TheOfficeExperts.com Anne Troy
Word and Excel Macros
Coming soon: wX
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top