View Single Post
  #12   Report Post  
Posted to microsoft.public.word.docmanagement
Ken Ken is offline
external usenet poster
 
Posts: 57
Default Can I create sequentially numbered documents on a server?

Ok.....Maybe I'm an Idiot......I've followed all of the steps listed to 1)
Set up Auto Numbering for Purchase orders when I write the Macro but, for
some reason, I can't get it to run properly. HELPPPPP!!!! I've used the
AutoNew @ MVP info and the other site you listed (separately of course) but,
I keep getting command errors when I try and use them.
I've established my po# on new po template in cell G4 but when I try and
run the Macro I do not get a new #. What to do, what to do???

"Jay Freedman" wrote:

You have too many "Sub" and "End Sub" lines. You should only have one
of each, with Sub AutoNew() at the beginning and with End Sub at the
end. You've commented out (that is, made useless) some important
lines, and you're also missing a couple of lines. It's a mess. :-)

The whole macro should look like this. Delete everything you have now,
and cut and paste the following code without changing anything.

'-------------------------------
Sub AutoNew()

Order = System.PrivateProfileString("G:\Templates\Settings .Txt", _
"MacroSettings", "Order")

If Order = "" Then
Order = 1050
Else
Order = Order + 1
End If

System.PrivateProfileString("G:\Templates\Settings .txt", _
"MacroSettings", "Order") = Order

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

End Sub
'-------------------------------

Finally, don't forget to insert a bookmark named "Order" in the body
of the template where you want the number to be inserted, as described
in the article.

--
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.

On Fri, 4 Aug 2006 14:57:01 -0700, Hettie
wrote:

I am still having difficutly. I am pasting what I have as the macro, can you
tell me if you see anything wrong? I have it saved under Templates on our G:
drive which all employees can access. I know I must be missing something.

Private Sub Document_New()

End Sub
'
' Sub AutoNew()
'Order= System.PrivateString("G:\Templates","macrosetting" ,"order")
If Order = "" Then
Order = 1050
System.PrivateProfileString("G:\Templates", "MacroSettings", "Order") =
OrderActiveDocument.Bookmarks("Order").Range.Inse rtBeforeFormat(Order, "00#")
ActiveDocument.SaveAsFileName = "path" & Format(Order, "00#")

End Sub

Sub AutoNew()
'
' AutoNew Macro
' Macro created 8/4/2006 by ihadmin
'

End Sub

"Jay Freedman" wrote:

Item 1: To let multiple people use the template, store it in a network
folder that all can access. I'll assume the folder is called
\\companyserver\publicshare\templates but it could be any valid name like
this, or it could be a folder on a mapped network drive (like N:\templates).
Then each person in their own copy of Word needs to go to Tools Options
File Locations, and modify the "Workgroup templates" location to point to
that shared folder.

This will cause the Purchase Order template -- and any other templates you
store there -- to appear in the list in the File New dialog in Word.
People should use the File New command to create new documents based on
the template. Nobody should actually _open_ the template (from File Open)
unless some change has to be made in the template itself.

Item 2: You need to copy the AutoNew macro code from the article and put it
into the Purchase Order template. Instructions for how to do this are at
http://www.gmayor.com/installing_macro.htm. Then you need to make a few
changes in the code to suit your requirements:

- There are two places in the macro that refer to a file named
"C:\Settings.Txt". In both places, change the path of the file to the same
folder where the template is stored, for example,
"\\companyserver\publicshare\templates\Settings.Tx t". (Don't try to use a
mapped drive path here; it'll cause errors if different people have the
location mapped to different drive letters.)

- Locate the lines of code that say

If Order = "" Then
Order = 1

and change them to

If Order = "" Then
Order = 1050

to start the numbering where you want.

--
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.

Hettie wrote:
Can you show me an actual example of how the formula should work. I
am very new with macros and don't understand the direction to the
link below. I have a Purchase Order document in Word that is a
template. I need to be able to start at 1050 and have the number
increase each time I open it. I will need multiple people to be able
to access this document from our company server. Can you help?

"Jay Freedman" wrote:

I assume you're using a solution like the one in
http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm, where the
current number is held in an external settings file
("C:\Settings.Txt" is the name used in that article).

The solution I suggest is that you create a separate settings file
for each type of purchase order. Then in each template, include the
name of the corresponding settings file. So, for instance, the
template used to make Admin P.O.s would have its AutoNew macro work
on AdminSettings.txt, while the one for Marketing P.O.s would work on
MarketingSettings.txt.

There is an alternative that uses a single settings file containing
different numbers for different templates. In this scheme, the file
name is the same in all templates, but each template uses a different
name in place of the "MacroSettings" parameter. (Within the settings
file, this becomes a label for a section of the settings. That
happens automatically.)

A final point: If multiple users will be creating P.O.s from these
templates, the settings file(s) should be on the server rather than
on a single workstation. This is mentioned, but not prominently, in
the article: "if more than one user needs access to the up-to-date
number, a text file can be saved in a shared area on the network."
To make this work, the file name in the AutoNew macros must contain
the path to the share instead of "C:\...".

--
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.