<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1039965" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1039965</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/computer-help/autoincrementing-reference-word#comment-1226128</link>
    <description> &lt;p&gt;Funny, about an hour ago our Office Manager called me to ask me how to do this in Excel for Purchase Orders.&lt;/p&gt;
&lt;p&gt;So I went looking and here is what I found, which I&#039;m sure could be used in word as well with some modification. This handles the issue of if they do not save the file, and stores the value in your registry.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://en.allexperts.com/q/Excel-1059/Auto-number-generation-1.htm&quot; class=&quot;bb-url&quot;&gt;http://en.allexperts.com/q/Excel-1059/Auto-number-generation-1.htm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is the version I put in the file (use ALT-F11 to open VBA editor), I will explain the features below it:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;Option Explicit&lt;br /&gt;&lt;br /&gt;Private Sub Workbook_BeforeClose(Cancel As Boolean)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim mpFile As String&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim mpValue As Long&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Static mpReentry As Boolean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tmpFile As String&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Not mpReentry Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mpReentry = True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Application.EnableEvents = False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cancel = True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mpValue = GetSetting(&amp;quot;IBP&amp;quot;, &amp;quot;PurcahseOrders&amp;quot;, &amp;quot;CurNum&amp;quot;, 1000) + 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If ThisWorkbook.Name = &amp;quot;PurchOrder.xls&amp;quot; Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039; This is the default name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If MsgBox(&amp;quot;Do you wish to save Purcahse Order #&amp;quot; &amp;amp; ActiveSheet.Range(&amp;quot;E4&amp;quot;).Value &amp;amp; &amp;quot;?&amp;quot;, vbYesNo, &amp;quot;Save File&amp;quot;) = vbYes Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmpFile = Application.DefaultFilePath &amp;amp; &amp;quot;\PurchOrder_&amp;quot; &amp;amp; mpValue - 1 &amp;amp; &amp;quot;.xls&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveWorkbook.SaveAs tmpFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SaveSetting &amp;quot;IBP&amp;quot;, &amp;quot;PurcahseOrders&amp;quot;, &amp;quot;CurNum&amp;quot;, mpValue&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Application.EnableEvents = True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThisWorkbook.Close savechanges:=False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mpReentry = False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim mpValue As Long&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If ThisWorkbook.Name = &amp;quot;PurchOrder.xls&amp;quot; Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Application.EnableEvents = False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cancel = True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox &amp;quot;Due to the built in numbers, you have to close this file to name/save it.&amp;quot;, vbOKOnly, &amp;quot;Save File&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Application.EnableEvents = True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Workbook_Open()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveSheet.Range(&amp;quot;E4&amp;quot;).Value = GetSetting(&amp;quot;IBP&amp;quot;, &amp;quot;PurcahseOrders&amp;quot;, &amp;quot;CurNum&amp;quot;, 1000)&lt;br /&gt;End Sub&lt;/code&gt;&lt;/div&gt;&#039;The &quot;template&quot; which isn&#039;t actually a template, but a base file is PurchOrder.xls When you open it, it gets the next # from the registry and places it in cell E4&lt;/p&gt;
&lt;p&gt;At this point it, you do not want it to be saved back out as PurchOrder.xls, as you want to keep that file safe. So if you hit save, it lets you know you have to close to save the file, at which point it auto saves to the same directory as the PurchOrder.xls that you opened, and names it PurchOrder_#####.xls  It then updates the registry with the new current value&lt;/p&gt;
&lt;p&gt;Now if you need to go back and edit the PO later, you can open it and do a save, as the filename is not PurchOrder.xls Only when you open the base one does it auto number.&lt;/p&gt;
&lt;p&gt;If you need to adjust the number that it is currently at, you can open the registry editor and the value will be at :[INDENT]HKEY_Current User[INDENT]Software[INDENT]VB and VBA Program Settings[INDENT]IBP  &lt;em&gt;(first value in the SaveSetting/GetSetting from code)&lt;/em&gt;[INDENT]PurchaseOrders &lt;em&gt;(second value in the SaveSetting/GetSetting from code)&lt;/em&gt;[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT]Also as an alternative for the REGEDIT shy, you could just create a simple spreadsheet where you type in a value on A1 and then set the code to be:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;Private Sub Workbook_BeforeClose(Cancel As Boolean)&lt;br /&gt;&amp;nbsp;&amp;nbsp; SaveSetting &amp;quot;IBP&amp;quot;, &amp;quot;PurcahseOrders&amp;quot;, &amp;quot;CurNum&amp;quot;, ActiveSheet.Range(&amp;quot;A1&amp;quot;).Value&lt;br /&gt;End Sub&lt;/code&gt;&lt;/div&gt;&#039;Anyhow, thought I would share this here for others.&lt;/p&gt;
&lt;p&gt;-Greg&lt;/p&gt;
 </description>
     <pubDate>Wed, 07 Nov 2007 18:16:16 +0000</pubDate>
 <dc:creator>Greg K</dc:creator>
 <guid isPermaLink="false">comment 1226128 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/computer-help/autoincrementing-reference-word#comment-1225632</link>
    <description> &lt;p&gt;Thanks guys, Ive managed to cobble together some great VB that does it, wasnt really sure about where to store the variable, I decided against placing it in the registry, and thus not tying the template to one machine, Ive stored it in a text file in the root of C. When the user clicks new, the program code searches the text file, and adds one to whatever numbers there, and displays it in the document at a position that I specified. The text file is updated and thus, everytime the user creates a new document, he gets his incrementing number. Not very tight I know, but works a treat&lt;/p&gt;
 </description>
     <pubDate>Wed, 24 Oct 2007 13:28:49 +0000</pubDate>
 <dc:creator>mfdc</dc:creator>
 <guid isPermaLink="false">comment 1225632 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/computer-help/autoincrementing-reference-word#comment-1225630</link>
    <description> &lt;p&gt;Not sure, but here are some considerations.&lt;/p&gt;
&lt;p&gt;I click New, it generates 0123 for that document. I change my mind and don&#039;t save it, just close it. Next time I hit new are you wanting it to be 0124 this time or still use the 0123 since it was never saved?&lt;/p&gt;
&lt;p&gt;Just some thought to put into the problem for anyone deciding to try to make this work.&lt;/p&gt;
&lt;p&gt;-Greg&lt;/p&gt;
 </description>
     <pubDate>Wed, 24 Oct 2007 13:23:36 +0000</pubDate>
 <dc:creator>Greg K</dc:creator>
 <guid isPermaLink="false">comment 1225630 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
