Bonjour,
Dans son message, < Claudine > écrivait :
In this message, < Claudine > wrote:
|| Hi,
||
|| Does anyone know how I can create a little macro or popup
|| box that instructs the user on how to use the template?
|| Just a few lines of text would be included.
||
From the VBA editor, locate your template name in the project pane on the
left. Then, in the tree structure under you template, fin the module called
"ThisDocument". Double click on that to access its code window. Once there,
use the dropdown list at the top of the code window, the one on the left
(the one that says General). Select Document in that list. Once you do that,
the following Sub will be added automatically in the code window:
'_______________________________________
Private Sub Document_New()
End Sub
'_______________________________________
Now, you have to decide. Do you want your instructions to appear only the
first time the use creates a document from your template? Or every single
time they open their document.
In the first case, just add your code in the Document_New sub. If the
latter, go to the dropdown list on the RIGHT, and select Open, the following
code will be added:
'_______________________________________
Private Sub Document_Open()
End Sub
'_______________________________________
If you need your code to be executed by both subs, create your own third sub
below those two, like
'_______________________________________
Private Sub MySub()
'Your code
End Sub
'_______________________________________
and use:
'_______________________________________
Private Sub Document_New()
MySub
End Sub
'_______________________________________
'_______________________________________
Private Sub Document_Open()
MySub
End Sub
'_______________________________________
This way your code will be executed both when the user creates and opens he
document.
Finally, for your instructions, the easiest is to use MsgBox, like:
'_______________________________________
Sub DisplayInstructions()
Dim MyInstructions As String
Dim MyInstructionsTitle As String
MyInstructions = "When using this template you have to know the following: "
_
& vbCrLf & "First, always regularly save your work. I cannot be held " _
& "responsible for your forgetfulness." & vbCrLf _
& "Second, use the toolbar to insert the autotexts." & vbCrLf & vbCrLf _
& "See how underscores are used to break continuous command lines " _
& "on several lines. Just make sure you enclose the string with quotes "
_
& "on one line, do not forget the spaces to space out the word at the "
_
& "end of a line and the following one on the next line. Then, type a "
_
& "space after the closing quote, followed by the underscore. Hit
""Enter"". " _
& "Type an ampersand (""&"") at the beginning of the following line,
then a " _
& "space followed by the opening quote for that line. And so on." _
& vbCrLf & vbCrLf & "Also, you can use ""vbCrLf"" to insert line
breaks."
MyInstructionsTitle = "Using the template"
MsgBox MyInstructions, vbInformation, MyInstructionsTitle
End Sub
'_______________________________________
Of course, this is a little extreme! Normally, for this much text, I would
use a userform... But, a message box will work just as well.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org