Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
Hi,
I have created Purchase Order word documents which I would like to put on our server. Each department's template is ready and I have used the Autonew macro to add sequential number to the P.O.s (everything is working fine on my computer) Now, my problem is that whatever template I am opening when working on the server, it does not differentiate the different P.O.s For example, I have an Admin P.O. #3, and if I want to open the Marketing P.O. for the first time, instead of having P.O. #1 I have P.O. #4. Would you know how to solve that problem? Thank you very much for your help. Adel |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
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. On Wed, 26 Jul 2006 13:56:01 -0700, adel wrote: Hi, I have created Purchase Order word documents which I would like to put on our server. Each department's template is ready and I have used the Autonew macro to add sequential number to the P.O.s (everything is working fine on my computer) Now, my problem is that whatever template I am opening when working on the server, it does not differentiate the different P.O.s For example, I have an Admin P.O. #3, and if I want to open the Marketing P.O. for the first time, instead of having P.O. #1 I have P.O. #4. Would you know how to solve that problem? Thank you very much for your help. Adel |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
Thank you very much Jay!
"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. On Wed, 26 Jul 2006 13:56:01 -0700, adel wrote: Hi, I have created Purchase Order word documents which I would like to put on our server. Each department's template is ready and I have used the Autonew macro to add sequential number to the P.O.s (everything is working fine on my computer) Now, my problem is that whatever template I am opening when working on the server, it does not differentiate the different P.O.s For example, I have an Admin P.O. #3, and if I want to open the Marketing P.O. for the first time, instead of having P.O. #1 I have P.O. #4. Would you know how to solve that problem? Thank you very much for your help. Adel |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
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. On Wed, 26 Jul 2006 13:56:01 -0700, adel wrote: Hi, I have created Purchase Order word documents which I would like to put on our server. Each department's template is ready and I have used the Autonew macro to add sequential number to the P.O.s (everything is working fine on my computer) Now, my problem is that whatever template I am opening when working on the server, it does not differentiate the different P.O.s For example, I have an Admin P.O. #3, and if I want to open the Marketing P.O. for the first time, instead of having P.O. #1 I have P.O. #4. Would you know how to solve that problem? Thank you very much for your help. Adel |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
I am working on a Purchase order form as well, but I can't get my number to
increase. I followed the directions on how to do it, but I must be doing something wrong. Can you help? Hettie "adel" wrote: Hi, I have created Purchase Order word documents which I would like to put on our server. Each department's template is ready and I have used the Autonew macro to add sequential number to the P.O.s (everything is working fine on my computer) Now, my problem is that whatever template I am opening when working on the server, it does not differentiate the different P.O.s For example, I have an Admin P.O. #3, and if I want to open the Marketing P.O. for the first time, instead of having P.O. #1 I have P.O. #4. Would you know how to solve that problem? Thank you very much for your help. Adel |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
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. |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
Thank you, I am really close, I just need to make a few adjustments. Have a
great day. You I have certainly made my day. I have been trying to do this for two days now. Hettie "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. |
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
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.Inser tBeforeFormat(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. |
#9
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
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. |
#10
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
Thanks Jay, I knew I had something in correct. I really appreciate your time
today helping me get this right. Have a great weekend. "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. |
#11
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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. |
#12
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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. |
#14
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
Thanks for the help, I'll be working on this today. I'll let you know how it
goes. Next question, to create a bookmark it should be in the cell where I have the PO# correct? How exactly do I create the bookmark? When I am using the Macro code listed here, do I use all of the quotation marks or, do I eliminate them and enter just the numbers? Also, VBA does not allow the underscore as part of the code line. Considering I figured out how to change out an engine by myself @ 19, I know I can figure this out. Or Maybe I should just buy a Really big hammer and smash the computer. (Just kidding) And, considering the only computer classes I've taken were back in 1983, I don't do too bad with them. Thx for saying I'm not an idiot, this I know, I just get frustrated with things I don't know how to do that well, YET!! "John McGhie [MVP - Word and Word Macinto" wrote: Hi Ken: Well, you're asking for Help, so you're not an idiot :-) You may be unfamiliar with this specific task, but you're not an idiot. There's one thing you can confidently leave to other people, and that is "putting Ken down". They'll do a grand job just on their own: you do not have to help... Now: Coupla things (and these are bits of knowledge you would have only if you did VBA all day for a living like Jay and I do...) 1) When you copy from a web browser and paste into the VBA editor, you are copying "non-breaking spaces". The internet rule is that multiple spaces should always be treated as "one" space. To keep the text indented, Internet Explorer substitutes "non-breaking" spaces for spaces. The Visual Basic Editor treats a space (character 32) and a non-breaking space (169, I think) as two distinctly different characters. Which they are. One is treated as a "space" ('nothing') the other is treated as "text" (a value). That will cause errors in your program. To remove the non-breaking spaces, copy your program code, start NotePad, paste into NotePad, select all again and Copy, then paste back into the VBA editor. NotePad can't reproduce non-breaking spaces, so it changes them all back to ordinary spaces :-) The other thing that is wrong is that programming languages are very sensitive to "lines" and "statements". A line is just that: from one side of the screen to another. But a "statement" may be longer than a line, and it must not be broken. To avoid breaking statements in VBA, where a statement continues over more than one line, we use a "continuation character" to indicate "New line, but don't compile the statement yet, it's not complete." The continuation character in VBA is "space underscore" like this _ You see how that line above ends with a space, then an underscore, then a hard return? If you look at the code Jay sent you, you will see a couple of those in there where he turned the lines over for you. You need to ensure that there is nothing after the space/underscore, and that the next line continues the same statement. Check those carefully. Then look through your code for red lines. Any line that turns all red has not been recognised by the compiler. There's something wrong with it. Now, try to RUN your macro. If there's anything wrong with it that did not show up at compile time, Word will stop and highlight the statement containing the error in yellow. I just checked your macro and it compiles fine. I can't run it here because I'm on a Mac (and your macro contains calls to the Windows registry!) 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 On 24/8/06 3:52 AM, in article , "Ken" wrote: 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.Inser tBeforeFormat(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. -- Please reply to the newsgroup to maintain the thread. Please do not email me unless I ask you to. John McGhie Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer Sydney, Australia +61 (0) 4 1209 1410 |
#15
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
Hi Ken,
Keep slogging, we'll get this thing working yet! You can put the bookmark anywhere in the body of the template that you want the number to appear. If you have a table with the characters PO# in a cell, you can put the bookmark immediately after the # character. To put in the bookmark, put the cursor at the place you want the number to appear, type a space character, and select the space character. Click the Insert menu item, and choose Bookmark. In the dialog that appears, type Order in the box at the top and click the Add button. Here's another little hint: Open the Tools | Options | View dialog and put a checkmark in the box for Bookmarks. Now you should see the bookmark in the template as a pair of square braces around the space character. In the macro code, leave the quotation marks exactly as they are -- that's important, because the code will malfunction without them. -- 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 Thu, 24 Aug 2006 06:16:02 -0700, Ken wrote: Thanks for the help, I'll be working on this today. I'll let you know how it goes. Next question, to create a bookmark it should be in the cell where I have the PO# correct? How exactly do I create the bookmark? When I am using the Macro code listed here, do I use all of the quotation marks or, do I eliminate them and enter just the numbers? Also, VBA does not allow the underscore as part of the code line. Considering I figured out how to change out an engine by myself @ 19, I know I can figure this out. Or Maybe I should just buy a Really big hammer and smash the computer. (Just kidding) And, considering the only computer classes I've taken were back in 1983, I don't do too bad with them. Thx for saying I'm not an idiot, this I know, I just get frustrated with things I don't know how to do that well, YET!! "John McGhie [MVP - Word and Word Macinto" wrote: Hi Ken: Well, you're asking for Help, so you're not an idiot :-) You may be unfamiliar with this specific task, but you're not an idiot. There's one thing you can confidently leave to other people, and that is "putting Ken down". They'll do a grand job just on their own: you do not have to help... Now: Coupla things (and these are bits of knowledge you would have only if you did VBA all day for a living like Jay and I do...) 1) When you copy from a web browser and paste into the VBA editor, you are copying "non-breaking spaces". The internet rule is that multiple spaces should always be treated as "one" space. To keep the text indented, Internet Explorer substitutes "non-breaking" spaces for spaces. The Visual Basic Editor treats a space (character 32) and a non-breaking space (169, I think) as two distinctly different characters. Which they are. One is treated as a "space" ('nothing') the other is treated as "text" (a value). That will cause errors in your program. To remove the non-breaking spaces, copy your program code, start NotePad, paste into NotePad, select all again and Copy, then paste back into the VBA editor. NotePad can't reproduce non-breaking spaces, so it changes them all back to ordinary spaces :-) The other thing that is wrong is that programming languages are very sensitive to "lines" and "statements". A line is just that: from one side of the screen to another. But a "statement" may be longer than a line, and it must not be broken. To avoid breaking statements in VBA, where a statement continues over more than one line, we use a "continuation character" to indicate "New line, but don't compile the statement yet, it's not complete." The continuation character in VBA is "space underscore" like this _ You see how that line above ends with a space, then an underscore, then a hard return? If you look at the code Jay sent you, you will see a couple of those in there where he turned the lines over for you. You need to ensure that there is nothing after the space/underscore, and that the next line continues the same statement. Check those carefully. Then look through your code for red lines. Any line that turns all red has not been recognised by the compiler. There's something wrong with it. Now, try to RUN your macro. If there's anything wrong with it that did not show up at compile time, Word will stop and highlight the statement containing the error in yellow. I just checked your macro and it compiles fine. I can't run it here because I'm on a Mac (and your macro contains calls to the Windows registry!) 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 On 24/8/06 3:52 AM, in article , "Ken" wrote: 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.Inser tBeforeFormat(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. -- Please reply to the newsgroup to maintain the thread. Please do not email me unless I ask you to. John McGhie Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer Sydney, Australia +61 (0) 4 1209 1410 |
#16
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Can I create sequentially numbered documents on a server?
Hi John, I was reading your reply and i am creating a P.O. just like the
others you have helped. I have copied your code and i have tried to run it. Now i am getting the top line in yellow highlight. I am uncertain how to fix the code, however, it is the exact one you sent with this reply from before. Any suggestions you might have i would really appreciate. Thanks Emiliy "John McGhie [MVP - Word and Word Macinto" wrote: Hi Ken: Well, you're asking for Help, so you're not an idiot :-) You may be unfamiliar with this specific task, but you're not an idiot. There's one thing you can confidently leave to other people, and that is "putting Ken down". They'll do a grand job just on their own: you do not have to help... Now: Coupla things (and these are bits of knowledge you would have only if you did VBA all day for a living like Jay and I do...) 1) When you copy from a web browser and paste into the VBA editor, you are copying "non-breaking spaces". The internet rule is that multiple spaces should always be treated as "one" space. To keep the text indented, Internet Explorer substitutes "non-breaking" spaces for spaces. The Visual Basic Editor treats a space (character 32) and a non-breaking space (169, I think) as two distinctly different characters. Which they are. One is treated as a "space" ('nothing') the other is treated as "text" (a value). That will cause errors in your program. To remove the non-breaking spaces, copy your program code, start NotePad, paste into NotePad, select all again and Copy, then paste back into the VBA editor. NotePad can't reproduce non-breaking spaces, so it changes them all back to ordinary spaces :-) The other thing that is wrong is that programming languages are very sensitive to "lines" and "statements". A line is just that: from one side of the screen to another. But a "statement" may be longer than a line, and it must not be broken. To avoid breaking statements in VBA, where a statement continues over more than one line, we use a "continuation character" to indicate "New line, but don't compile the statement yet, it's not complete." The continuation character in VBA is "space underscore" like this _ You see how that line above ends with a space, then an underscore, then a hard return? If you look at the code Jay sent you, you will see a couple of those in there where he turned the lines over for you. You need to ensure that there is nothing after the space/underscore, and that the next line continues the same statement. Check those carefully. Then look through your code for red lines. Any line that turns all red has not been recognised by the compiler. There's something wrong with it. Now, try to RUN your macro. If there's anything wrong with it that did not show up at compile time, Word will stop and highlight the statement containing the error in yellow. I just checked your macro and it compiles fine. I can't run it here because I'm on a Mac (and your macro contains calls to the Windows registry!) 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 On 24/8/06 3:52 AM, in article , "Ken" wrote: 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.Inser tBeforeFormat(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. -- Please reply to the newsgroup to maintain the thread. Please do not email me unless I ask you to. John McGhie Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer Sydney, Australia +61 (0) 4 1209 1410 |
#17
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
It worked, but...
Jay,
I followed your instructions and added your code to my macro to make a new number sequentially appear on my new PO, however the template that I used has a [100] and my new number appears before it. How do I get rid of the [100] from the original template? Thanks- Pat "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. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I generate a document number for documents on my server? | Microsoft Word Help | |||
Create multiple documents from one and vice versa | Microsoft Word Help | |||
Cannot create new documents in Word or edit existing documents. | Microsoft Word Help | |||
duplex printing page numbered documents | Microsoft Word Help | |||
How do I create an outline with numbered headings in Word? | Microsoft Word Help |