Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
snulton snulton is offline
external usenet poster
 
Posts: 25
Default How do I set up automatically suceeding numbers in Word?

I have a template that has a space for a number. I want each successive
document opened using that template to have a new number that is the next
number in sucession, i.e. - after opening 20071001, the next time that I
access that template should open 2001002.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How do I set up automatically suceeding numbers in Word?

snulton wrote:
I have a template that has a space for a number. I want each
successive document opened using that template to have a new number
that is the next number in sucession, i.e. - after opening 20071001,
the next time that I access that template should open 2001002.


See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


  #3   Report Post  
Posted to microsoft.public.word.docmanagement
snulton snulton is offline
external usenet poster
 
Posts: 25
Default How do I set up automatically suceeding numbers in Word?

I have set up the Macro as on the page however when I attempt to open the
template Microsoft Basic pops up with the messege "The macros in this project
are disabled. Please refer to the online help or documentation of the host
application to determine how to enable macros." then I got a popup trying to
debug the first of the last two commands.

Also is the value "00#" a locked in numeric value or will it work with eight
digits?

"Jay Freedman" wrote:

snulton wrote:
I have a template that has a space for a number. I want each
successive document opened using that template to have a new number
that is the next number in sucession, i.e. - after opening 20071001,
the next time that I access that template should open 2001002.


See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.



  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How do I set up automatically suceeding numbers in Word?

Did you set up the macro in a template stored in your Templates
folder? Word really doesn't like macros in documents, or in templates
that aren't in the Templates folder, because that's a favorite way to
spread macro viruses.

Assuming it is in a template, go to Tools Macro Security and set
the security level to Medium. On the second tab of the dialog, check
the box for "Trust all installed templates and add-ins". That should
make sure the macros are enabled.

The number-format pattern will work with eight digits; just change it
to "0000000#".

On Fri, 5 Oct 2007 16:08:01 -0700, snulton
wrote:

I have set up the Macro as on the page however when I attempt to open the
template Microsoft Basic pops up with the messege "The macros in this project
are disabled. Please refer to the online help or documentation of the host
application to determine how to enable macros." then I got a popup trying to
debug the first of the last two commands.

Also is the value "00#" a locked in numeric value or will it work with eight
digits?

"Jay Freedman" wrote:

snulton wrote:
I have a template that has a space for a number. I want each
successive document opened using that template to have a new number
that is the next number in sucession, i.e. - after opening 20071001,
the next time that I access that template should open 2001002.


See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
  #5   Report Post  
Posted to microsoft.public.word.docmanagement
snulton snulton is offline
external usenet poster
 
Posts: 25
Default How do I set up automatically suceeding numbers in Word?

It was'nt in my Templates folder because I was testing it out before I put it
on my Server which is where I store all my templates related to my business.
I tried to preset the start number to the next one that we need
(i.e."2007100#") but it did not open a successive number it opened a document
with a number 2007100120071001. The same thing happened when I had only the
three digit number 001 turned into 001001 and it was that way on each one I
opened.

"Jay Freedman" wrote:

Did you set up the macro in a template stored in your Templates
folder? Word really doesn't like macros in documents, or in templates
that aren't in the Templates folder, because that's a favorite way to
spread macro viruses.

Assuming it is in a template, go to Tools Macro Security and set
the security level to Medium. On the second tab of the dialog, check
the box for "Trust all installed templates and add-ins". That should
make sure the macros are enabled.

The number-format pattern will work with eight digits; just change it
to "0000000#".

On Fri, 5 Oct 2007 16:08:01 -0700, snulton
wrote:

I have set up the Macro as on the page however when I attempt to open the
template Microsoft Basic pops up with the messege "The macros in this project
are disabled. Please refer to the online help or documentation of the host
application to determine how to enable macros." then I got a popup trying to
debug the first of the last two commands.

Also is the value "00#" a locked in numeric value or will it work with eight
digits?

"Jay Freedman" wrote:

snulton wrote:
I have a template that has a space for a number. I want each
successive document opened using that template to have a new number
that is the next number in sucession, i.e. - after opening 20071001,
the next time that I access that template should open 2001002.

See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.



  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How do I set up automatically suceeding numbers in Word?

I think you're misunderstanding the "00#" expression. That is just
supposed to represent the form of the number -- how many digits to
display -- and not the number itself. You don't change that expression
to the start number.

From the example you gave, I suspect what you're trying to do is
create a number where the first four digits are the year, the next two
are the month, and the last two are a sequence number that starts over
at 1 for each month. If that's true, you're going about it wrong -- if
you put the fixed string "200710" at the beginning, that's fine for
October 2007 but it will be wrong for November, and even more wrong
next year. The macro can take care of the year and month for you with
just a little extra programming. Replace the lines

ActiveDocument.Bookmarks("Order").Range.InsertBefo re Format(Order,
"00#")
ActiveDocument.SaveAs FileName:="path" & Format(Order, "00#")

with these lines (to avoid mistakes, use copy/paste instead of trying
to retype):

ActiveDocument.Bookmarks("Order").Range.InsertBefo re _
Format(Now, "yyyyMM") & Format(Order, "0#")
ActiveDocument.SaveAs FileName:="path" & _
Format(Now, "yyyyMM") & Format(Order, "0#")

Note that you have to replace "path" in the third line with the actual
path to the folder where you want the document to be saved.

The other thing is that, on the first day of each month, you have to
delete the Settings.txt file and let the macro create a new one that
contains the number 1, so the number in the first document will be
like 20071101.

On Fri, 5 Oct 2007 16:46:02 -0700, snulton
wrote:

It was'nt in my Templates folder because I was testing it out before I put it
on my Server which is where I store all my templates related to my business.
I tried to preset the start number to the next one that we need
(i.e."2007100#") but it did not open a successive number it opened a document
with a number 2007100120071001. The same thing happened when I had only the
three digit number 001 turned into 001001 and it was that way on each one I
opened.

"Jay Freedman" wrote:

Did you set up the macro in a template stored in your Templates
folder? Word really doesn't like macros in documents, or in templates
that aren't in the Templates folder, because that's a favorite way to
spread macro viruses.

Assuming it is in a template, go to Tools Macro Security and set
the security level to Medium. On the second tab of the dialog, check
the box for "Trust all installed templates and add-ins". That should
make sure the macros are enabled.

The number-format pattern will work with eight digits; just change it
to "0000000#".

On Fri, 5 Oct 2007 16:08:01 -0700, snulton
wrote:

I have set up the Macro as on the page however when I attempt to open the
template Microsoft Basic pops up with the messege "The macros in this project
are disabled. Please refer to the online help or documentation of the host
application to determine how to enable macros." then I got a popup trying to
debug the first of the last two commands.

Also is the value "00#" a locked in numeric value or will it work with eight
digits?

"Jay Freedman" wrote:

snulton wrote:
I have a template that has a space for a number. I want each
successive document opened using that template to have a new number
that is the next number in sucession, i.e. - after opening 20071001,
the next time that I access that template should open 2001002.

See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
  #7   Report Post  
Posted to microsoft.public.word.docmanagement
snulton snulton is offline
external usenet poster
 
Posts: 25
Default How do I set up automatically suceeding numbers in Word?

I hope that I didn't upset you with my insessent questions, but I am going
to repost this:

I am probably beginning to sound really stupid. So let me see if I have it
from the beginning.

First I open a template (.dot) which automatically creates a document (.doc)
that has a name "Document* (* = the number of the document opened and saved)
then in that document I go to File New which opens a task pane that I then
click on the Link for "On my Computer", I then receive a new Template (.dot)
named "path0*****.dot, I then set my bookmark where I want the sequential
numbers and then Go to Tools Macro Macros and am given a choice in the
window that opens a blank space for Macro name, a bigger area that has
AutoExec.MAIN, AutoExit.MAIN, and RunFineReader, with active buttons
"Create", "Organizer", and "Close".

Logic tells me that I would then "Create" AutoNew. This then opens Microsoft
Visual Basic which has a panel that has a choice of "FineReader6SprintTools",
"Normal", "Project (Document 1)" (with no modules), "TemplateProject (Live
Meeting Toolbar Customizations)" and finally "TemplateProject (SerRepCon)"
[the name of the original template], both the "Project (Document 1)" and the
"TemplateProject (SerRepCon)" have "ThisDocument" when opening "Microsoft
Word Objects". Which one do I use?

The code window that opens caries the header of whichever main catagory is
highlighted. This is the window that I put the AutoNew language.

After this is done I would then click on the Save icon on the toolbar in
Microsoft Visual Basic and shut window. then I would go to File SaveAs and
name the document the same as the name used in the Macro before "sequence".

Is this correct? Inf not Please correct within the messege.


"Jay Freedman" wrote:

snulton wrote:
I have a template that has a space for a number. I want each
successive document opened using that template to have a new number
that is the next number in sucession, i.e. - after opening 20071001,
the next time that I access that template should open 2001002.


See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.



  #8   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How do I set up automatically suceeding numbers in Word?

Hi Scott,

I'm not upset; this is a complicated setup. But it does seem that you missed
some fundamental principles, and I'm glad of the chance to start at the
bottom and clear things up.

Your paragraph "First I open a template ..." is not correct. Please wipe
that blackboard clean, and we'll start from the beginning.

I'll assume you have a template named SerRepCon.dot that contains the text
of a contract. Within that text are some form fields. For each customer,
you want to make a document based on the template, in which the form fields
will be filled in differently. Some place in the document you want to put a
sequence number that will be different for each document, and that number
will also become part of the document's file name. Right so far?

I'll also assume that at this point the SerRepCon.dot template doesn't
contain any macros, and that the template file is stored in your Templates
folder (something like C:\Documents and Settings\snulton\Application
Data\Microsoft\Templates).

Start the Word program. Click File Open (_not_ File New at this time).
Set the "Files of type" dropdown to "Document Templates (*.dot)". Use the
"Look in" dropdown to navigate to the Templates folder, select
SerRepCon.dot, and click OK. You're now able to edit the SerRepCon.dot
template itself, not any document based on it.

Put the cursor in the location where you want the sequence number to appear,
and insert a bookmark named "Order". That same bookmark will automatically
appear in each document you base on this template.

Open the VBA editor. The Projects pane should include icons for Normal
(because Normal.dot is always loaded), FineReader6SprintTools (which is an
add-in from the FineReader program), Live Meeting Toolbar Customizations
(another add-in), and SerRepCon. If you followed the directions exactly,
there shouldn't be any others -- but if there are, ignore them.

Select and expand the icon for "TemplateProject (SerRepCon)". It should
contain a folder named "Microsoft Word Objects", in which there is a
"ThisDocument" icon. Ignore those. Click the Insert Module command on the
menu (in the VBA editor, not in Word's window). That will create a Modules
folder under "TemplateProject (SerRepCon)", containing a "Module1" icon. To
verify that you're in the right place, the code window should be empty and
the title bar should say "Microsoft Visual Basic - SerRepCon - [Module1
(Code)]".

Click in the code window and paste in the code of the AutoNew macro from our
recent posts. Make sure it includes the lines to unprotect and reprotect the
form. The two lines that mention System.PrivateProfileString should contain
"C:\SerRepCon Sequence.txt" as the name of the file to contain the current
sequence number.

Close the VBA editor. Turn on form protection (click the lock icon on the
Forms toolbar), save the template, and close it.

Open the File New dialog (_not_ File Open -- now you're going to create a
document based on the template). Select the SerRepCon template and click OK.
You should see a document named "path00001.doc" that is a protected form
with the sequence number 00001 at the place marked by the Order bookmark.

Each time you go to File New and select the SerRepCon template as the
basis for a new document, you should get another document and the sequence
number should be greater by 1 than the one before.

Now repeat all the previous steps for the template of another kind of form;
the only difference should be that the lines that mention
System.PrivateProfileString should contain the name of a different text
file -- one related to that particular template.

By the way, I don't think you really want the word "path" as part of the
document's filename. The reason it's there now is that the original article
on word.mvps.org shows it there -- but it was meant to represent the folder
location (that is, the path from C:\ to the folder where you want the
document to be stored), not the literal word "path". If you just want to
store all the documents in the My Documents folder, you could change the
Save statement to something like

ActiveDocument.SaveAs FileName:="SerRepCon" & Format(Order, "0000#")

so the actual name of a document based on this template would be something
like SerRepCon00001.doc. Because the filename doesn't contain any
information about the folder, Word automatically uses whatever folder you
have set as the Documents location in the Tools Options File Locations
dialog -- and by default that's the My Documents folder.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

snulton wrote:
I hope that I didn't upset you with my insessent questions, but I am
going to repost this:

I am probably beginning to sound really stupid. So let me see if I
have it from the beginning.

First I open a template (.dot) which automatically creates a document
(.doc) that has a name "Document* (* = the number of the document
opened and saved) then in that document I go to File New which
opens a task pane that I then click on the Link for "On my Computer",
I then receive a new Template (.dot) named "path0*****.dot, I then
set my bookmark where I want the sequential numbers and then Go to
Tools Macro Macros and am given a choice in the window that opens
a blank space for Macro name, a bigger area that has AutoExec.MAIN,
AutoExit.MAIN, and RunFineReader, with active buttons "Create",
"Organizer", and "Close".

Logic tells me that I would then "Create" AutoNew. This then opens
Microsoft Visual Basic which has a panel that has a choice of
"FineReader6SprintTools", "Normal", "Project (Document 1)" (with no
modules), "TemplateProject (Live Meeting Toolbar Customizations)" and
finally "TemplateProject (SerRepCon)" [the name of the original
template], both the "Project (Document 1)" and the "TemplateProject
(SerRepCon)" have "ThisDocument" when opening "Microsoft Word
Objects". Which one do I use?

The code window that opens caries the header of whichever main
catagory is highlighted. This is the window that I put the AutoNew
language.

After this is done I would then click on the Save icon on the toolbar
in Microsoft Visual Basic and shut window. then I would go to File
SaveAs and name the document the same as the name used in the Macro
before "sequence".

Is this correct? Inf not Please correct within the messege.


"Jay Freedman" wrote:

snulton wrote:
I have a template that has a space for a number. I want each
successive document opened using that template to have a new number
that is the next number in sucession, i.e. - after opening 20071001,
the next time that I access that template should open 2001002.


See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.



  #9   Report Post  
Posted to microsoft.public.word.docmanagement
snulton snulton is offline
external usenet poster
 
Posts: 25
Default How do I set up automatically suceeding numbers in Word?

Thank you Jay;

I got it to work, however if the lock icon is clicked to protect the form
when that template is accessed an Error messege:
"Run-time error `4605`
This method or property is not available because the object refers to a
protected area of the document. appears. When clicking on "De-bug" The VBA
opens the AutoNew window and highlites the second to last line before "End
Sub"

But without the document "protected" the numbering works.

Thanks again

"Jay Freedman" wrote:

Hi Scott,

I'm not upset; this is a complicated setup. But it does seem that you missed
some fundamental principles, and I'm glad of the chance to start at the
bottom and clear things up.

Your paragraph "First I open a template ..." is not correct. Please wipe
that blackboard clean, and we'll start from the beginning.

I'll assume you have a template named SerRepCon.dot that contains the text
of a contract. Within that text are some form fields. For each customer,
you want to make a document based on the template, in which the form fields
will be filled in differently. Some place in the document you want to put a
sequence number that will be different for each document, and that number
will also become part of the document's file name. Right so far?

I'll also assume that at this point the SerRepCon.dot template doesn't
contain any macros, and that the template file is stored in your Templates
folder (something like C:\Documents and Settings\snulton\Application
Data\Microsoft\Templates).

Start the Word program. Click File Open (_not_ File New at this time).
Set the "Files of type" dropdown to "Document Templates (*.dot)". Use the
"Look in" dropdown to navigate to the Templates folder, select
SerRepCon.dot, and click OK. You're now able to edit the SerRepCon.dot
template itself, not any document based on it.

Put the cursor in the location where you want the sequence number to appear,
and insert a bookmark named "Order". That same bookmark will automatically
appear in each document you base on this template.

Open the VBA editor. The Projects pane should include icons for Normal
(because Normal.dot is always loaded), FineReader6SprintTools (which is an
add-in from the FineReader program), Live Meeting Toolbar Customizations
(another add-in), and SerRepCon. If you followed the directions exactly,
there shouldn't be any others -- but if there are, ignore them.

Select and expand the icon for "TemplateProject (SerRepCon)". It should
contain a folder named "Microsoft Word Objects", in which there is a
"ThisDocument" icon. Ignore those. Click the Insert Module command on the
menu (in the VBA editor, not in Word's window). That will create a Modules
folder under "TemplateProject (SerRepCon)", containing a "Module1" icon. To
verify that you're in the right place, the code window should be empty and
the title bar should say "Microsoft Visual Basic - SerRepCon - [Module1
(Code)]".

Click in the code window and paste in the code of the AutoNew macro from our
recent posts. Make sure it includes the lines to unprotect and reprotect the
form. The two lines that mention System.PrivateProfileString should contain
"C:\SerRepCon Sequence.txt" as the name of the file to contain the current
sequence number.

Close the VBA editor. Turn on form protection (click the lock icon on the
Forms toolbar), save the template, and close it.

Open the File New dialog (_not_ File Open -- now you're going to create a
document based on the template). Select the SerRepCon template and click OK.
You should see a document named "path00001.doc" that is a protected form
with the sequence number 00001 at the place marked by the Order bookmark.

Each time you go to File New and select the SerRepCon template as the
basis for a new document, you should get another document and the sequence
number should be greater by 1 than the one before.

Now repeat all the previous steps for the template of another kind of form;
the only difference should be that the lines that mention
System.PrivateProfileString should contain the name of a different text
file -- one related to that particular template.

By the way, I don't think you really want the word "path" as part of the
document's filename. The reason it's there now is that the original article
on word.mvps.org shows it there -- but it was meant to represent the folder
location (that is, the path from C:\ to the folder where you want the
document to be stored), not the literal word "path". If you just want to
store all the documents in the My Documents folder, you could change the
Save statement to something like

ActiveDocument.SaveAs FileName:="SerRepCon" & Format(Order, "0000#")

so the actual name of a document based on this template would be something
like SerRepCon00001.doc. Because the filename doesn't contain any
information about the folder, Word automatically uses whatever folder you
have set as the Documents location in the Tools Options File Locations
dialog -- and by default that's the My Documents folder.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

snulton wrote:
I hope that I didn't upset you with my insessent questions, but I am
going to repost this:

I am probably beginning to sound really stupid. So let me see if I
have it from the beginning.

First I open a template (.dot) which automatically creates a document
(.doc) that has a name "Document* (* = the number of the document
opened and saved) then in that document I go to File New which
opens a task pane that I then click on the Link for "On my Computer",
I then receive a new Template (.dot) named "path0*****.dot, I then
set my bookmark where I want the sequential numbers and then Go to
Tools Macro Macros and am given a choice in the window that opens
a blank space for Macro name, a bigger area that has AutoExec.MAIN,
AutoExit.MAIN, and RunFineReader, with active buttons "Create",
"Organizer", and "Close".

Logic tells me that I would then "Create" AutoNew. This then opens
Microsoft Visual Basic which has a panel that has a choice of
"FineReader6SprintTools", "Normal", "Project (Document 1)" (with no
modules), "TemplateProject (Live Meeting Toolbar Customizations)" and
finally "TemplateProject (SerRepCon)" [the name of the original
template], both the "Project (Document 1)" and the "TemplateProject
(SerRepCon)" have "ThisDocument" when opening "Microsoft Word
Objects". Which one do I use?

The code window that opens caries the header of whichever main
catagory is highlighted. This is the window that I put the AutoNew
language.

After this is done I would then click on the Save icon on the toolbar
in Microsoft Visual Basic and shut window. then I would go to File
SaveAs and name the document the same as the name used in the Macro
before "sequence".

Is this correct? Inf not Please correct within the messege.


"Jay Freedman" wrote:

snulton wrote:
I have a template that has a space for a number. I want each
successive document opened using that template to have a new number
that is the next number in sucession, i.e. - after opening 20071001,
the next time that I access that template should open 2001002.

See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.




  #10   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How do I set up automatically suceeding numbers in Word?

Did you include the code to unprotect the document and the code to protect
the document? This was in my post of 10/182007:

- ... insert new code before and after the InsertBefore line
like this:

If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If

ActiveDocument.Bookmarks("Order").Range.InsertBefo re Format(Order,
"0000#")

ActiveDocument.Protect

ActiveDocument.SaveAs FileName:="path" & Format(Order, "0000#")


That will turn off the protection just long enough to insert the sequence
number, and then turn the protection on again.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

snulton wrote:
Thank you Jay;

I got it to work, however if the lock icon is clicked to protect the
form when that template is accessed an Error messege:
"Run-time error `4605`
This method or property is not available because the object refers to
a protected area of the document. appears. When clicking on "De-bug"
The VBA opens the AutoNew window and highlites the second to last
line before "End Sub"

But without the document "protected" the numbering works.

Thanks again

"Jay Freedman" wrote:

Hi Scott,

I'm not upset; this is a complicated setup. But it does seem that
you missed some fundamental principles, and I'm glad of the chance
to start at the bottom and clear things up.

Your paragraph "First I open a template ..." is not correct. Please
wipe that blackboard clean, and we'll start from the beginning.

I'll assume you have a template named SerRepCon.dot that contains
the text of a contract. Within that text are some form fields. For
each customer, you want to make a document based on the template, in
which the form fields will be filled in differently. Some place in
the document you want to put a sequence number that will be
different for each document, and that number will also become part
of the document's file name. Right so far?

I'll also assume that at this point the SerRepCon.dot template
doesn't contain any macros, and that the template file is stored in
your Templates folder (something like C:\Documents and
Settings\snulton\Application Data\Microsoft\Templates).

Start the Word program. Click File Open (_not_ File New at this
time). Set the "Files of type" dropdown to "Document Templates
(*.dot)". Use the "Look in" dropdown to navigate to the Templates
folder, select SerRepCon.dot, and click OK. You're now able to edit
the SerRepCon.dot template itself, not any document based on it.

Put the cursor in the location where you want the sequence number to
appear, and insert a bookmark named "Order". That same bookmark will
automatically appear in each document you base on this template.

Open the VBA editor. The Projects pane should include icons for
Normal (because Normal.dot is always loaded), FineReader6SprintTools
(which is an add-in from the FineReader program), Live Meeting
Toolbar Customizations (another add-in), and SerRepCon. If you
followed the directions exactly, there shouldn't be any others --
but if there are, ignore them.

Select and expand the icon for "TemplateProject (SerRepCon)". It
should contain a folder named "Microsoft Word Objects", in which
there is a "ThisDocument" icon. Ignore those. Click the Insert
Module command on the menu (in the VBA editor, not in Word's
window). That will create a Modules folder under "TemplateProject
(SerRepCon)", containing a "Module1" icon. To verify that you're in
the right place, the code window should be empty and the title bar
should say "Microsoft Visual Basic - SerRepCon - [Module1 (Code)]".

Click in the code window and paste in the code of the AutoNew macro
from our recent posts. Make sure it includes the lines to unprotect
and reprotect the form. The two lines that mention
System.PrivateProfileString should contain "C:\SerRepCon
Sequence.txt" as the name of the file to contain the current
sequence number.

Close the VBA editor. Turn on form protection (click the lock icon
on the Forms toolbar), save the template, and close it.

Open the File New dialog (_not_ File Open -- now you're going to
create a document based on the template). Select the SerRepCon
template and click OK. You should see a document named
"path00001.doc" that is a protected form with the sequence number
00001 at the place marked by the Order bookmark.

Each time you go to File New and select the SerRepCon template as
the basis for a new document, you should get another document and
the sequence number should be greater by 1 than the one before.

Now repeat all the previous steps for the template of another kind
of form; the only difference should be that the lines that mention
System.PrivateProfileString should contain the name of a different
text file -- one related to that particular template.

By the way, I don't think you really want the word "path" as part of
the document's filename. The reason it's there now is that the
original article on word.mvps.org shows it there -- but it was meant
to represent the folder location (that is, the path from C:\ to the
folder where you want the document to be stored), not the literal
word "path". If you just want to store all the documents in the My
Documents folder, you could change the Save statement to something
like

ActiveDocument.SaveAs FileName:="SerRepCon" & Format(Order, "0000#")

so the actual name of a document based on this template would be
something like SerRepCon00001.doc. Because the filename doesn't
contain any information about the folder, Word automatically uses
whatever folder you have set as the Documents location in the Tools
Options File Locations dialog -- and by default that's the My

Documents folder.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

snulton wrote:
I hope that I didn't upset you with my insessent questions, but I
am going to repost this:

I am probably beginning to sound really stupid. So let me see if I
have it from the beginning.

First I open a template (.dot) which automatically creates a
document (.doc) that has a name "Document* (* = the number of the
document opened and saved) then in that document I go to File New
which opens a task pane that I then click on the Link for "On my
Computer", I then receive a new Template (.dot) named
"path0*****.dot, I then set my bookmark where I want the sequential
numbers and then Go to Tools Macro Macros and am given a choice
in the window that opens a blank space for Macro name, a bigger
area that has AutoExec.MAIN, AutoExit.MAIN, and RunFineReader, with
active buttons "Create", "Organizer", and "Close".

Logic tells me that I would then "Create" AutoNew. This then opens
Microsoft Visual Basic which has a panel that has a choice of
"FineReader6SprintTools", "Normal", "Project (Document 1)" (with no
modules), "TemplateProject (Live Meeting Toolbar Customizations)"
and finally "TemplateProject (SerRepCon)" [the name of the original
template], both the "Project (Document 1)" and the "TemplateProject
(SerRepCon)" have "ThisDocument" when opening "Microsoft Word
Objects". Which one do I use?

The code window that opens caries the header of whichever main
catagory is highlighted. This is the window that I put the AutoNew
language.

After this is done I would then click on the Save icon on the
toolbar in Microsoft Visual Basic and shut window. then I would go
to File SaveAs and name the document the same as the name used in
the Macro before "sequence".

Is this correct? Inf not Please correct within the messege.


"Jay Freedman" wrote:

snulton wrote:
I have a template that has a space for a number. I want each
successive document opened using that template to have a new
number that is the next number in sucession, i.e. - after opening
20071001, the next time that I access that template should open
2001002.

See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.





Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
In Word, how can I automatically insert a comma between numbers? sharris Microsoft Word Help 5 May 16th 23 02:48 AM
how do i automatically phone numbers on a word document? tlr Microsoft Word Help 0 July 5th 06 10:40 PM
How to add a counter in Word? The numbers automatically go up Jenn Microsoft Word Help 1 January 10th 06 09:42 PM
Can I automatically add superscript sentence numbers in Word? PatB Microsoft Word Help 1 December 8th 05 03:26 PM
How do I get Word to automatically add page numbers for each colu. JohnP Page Layout 1 January 1st 05 11:51 AM


All times are GMT +1. The time now is 10:21 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"