Hi!

For my template, I've created an autonew macro that displays a userform
prompting the user for a title, code, and date. The responses are displayed
in the file via bookmarks.

I've also created an autoopen macro that prompts the user for a new date.
The problem is that the new date gets added to the bookmark in front of the
existing date (entered when the file was created. I end up with this:

10 Feb 200609 Feb 2006

Any suggestions on how to fix this would be welcome!

Thanks!

Beth

Re: Userforms and bookmarks by Doug

Doug
Fri Feb 10 13:01:59 CST 2006

Instead of using bookmarks, insert { DOCVARIABLE varname } fields in the
document and in the code in the user form, use

With ActiveDocument
.Variables("varname").Value = txtcontrolname
etc.
.Range.Fields.Update
End With

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Beth Brooks" <BethBrooks@discussions.microsoft.com> wrote in message
news:85D27FB6-7778-4B42-BEA1-F9A4C280359C@microsoft.com...
> Hi!
>
> For my template, I've created an autonew macro that displays a userform
> prompting the user for a title, code, and date. The responses are
> displayed
> in the file via bookmarks.
>
> I've also created an autoopen macro that prompts the user for a new date.
> The problem is that the new date gets added to the bookmark in front of
> the
> existing date (entered when the file was created. I end up with this:
>
> 10 Feb 200609 Feb 2006
>
> Any suggestions on how to fix this would be welcome!
>
> Thanks!
>
> Beth



Re: Userforms and bookmarks by BethBrooks

BethBrooks
Tue Feb 14 09:30:31 CST 2006

Doug,

Thank you! That worked very well. I have a couple of follow-up questions:

The variables are used in a template. When a user creates a new document
based on this template, a userform prompts them for the title, code, and
date. However, when I open the template, I don't get that prompt, so the
variables have no initial value. I tried setting a value for each of the
fields, but I must have done it in the wrong place, because it didn't work.
How (more importantly where) do I set an initial value for each variable?
(BTW, for the short term, I've created a new file based on the template, set
the variable values using the userform, and then saved the resulting document
as a template. But I'd like to know how to fix this issue for the long term.)

Second, I'd like to give the users of this template a way to modify the
values of these three variables at will, in case they typed something
incorrectly or the information changes. I'd like to put a button on a toolbar
that brings up the userform displayed when a new file is created. Is that
possible and, if so, how do I do it?

I very much appreciate your help! I'm an editor trying to fill the role of a
developer and I'm in way over my head!

Thanks!

Beth

Re: Userforms and bookmarks by Doug

Doug
Tue Feb 14 14:45:06 CST 2006

A value can only be assigned to a variable using code. Normally, the user
should not be opening the template. You can put a button on the toolbar
that runs the autonew macro. You can use code such as the following to
populate the controls on the form with the data from the variables when the
user reloads it when they are working in document:

Private Sub UserForm_Initialize()
With ActiveDocument
txtCompany = .Variables("Company").Value
txtProject = .Variables("Project").Value
txtDocNum = .Variables("DocNum").Value
txtRevNum = .Variables("Revision").Value
txtDocTitle = .Variables("DocTitle").Value
End With
End Sub



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Beth Brooks" <BethBrooks@discussions.microsoft.com> wrote in message
news:4B5ACEAE-91E0-4949-8428-9B29CEEA5341@microsoft.com...
> Doug,
>
> Thank you! That worked very well. I have a couple of follow-up questions:
>
> The variables are used in a template. When a user creates a new document
> based on this template, a userform prompts them for the title, code, and
> date. However, when I open the template, I don't get that prompt, so the
> variables have no initial value. I tried setting a value for each of the
> fields, but I must have done it in the wrong place, because it didn't
> work.
> How (more importantly where) do I set an initial value for each variable?
> (BTW, for the short term, I've created a new file based on the template,
> set
> the variable values using the userform, and then saved the resulting
> document
> as a template. But I'd like to know how to fix this issue for the long
> term.)
>
> Second, I'd like to give the users of this template a way to modify the
> values of these three variables at will, in case they typed something
> incorrectly or the information changes. I'd like to put a button on a
> toolbar
> that brings up the userform displayed when a new file is created. Is that
> possible and, if so, how do I do it?
>
> I very much appreciate your help! I'm an editor trying to fill the role of
> a
> developer and I'm in way over my head!
>
> Thanks!
>
> Beth