Sequential Numbering in Word 2003 and Recycling unused numbers

Once again, I am stuck in Macro world which is quickly consuming me :) It is 
though, quite addictive and I am determined to win the fight I'm having with 
my PC.
I work for a company which uses network servers so the document needs to be 
accessed by different people but not necessarily at the same time. We operate 
Windows XP Word 2003.
I am trying to create a document that will open with a sequential number, 
but if the document is not used or opened accidentally then the number it has 
generated needs to be recycled for auditing purposes. I seem to be able to 
get the number to sequentially generate but the recycling of the number has 
got me absolutely beat. I can’t for the life of me understand how to do it or 
what I am doing wrong. 
The other people who would be accessing the document are not very computer 
literate and therefore I have tried to get the macro to AutoOpen so the 
number is generated for them.
I have tried using code that MVP's have provided other users of the forum 
with, but when I try incorporating all different macros I just make a big 
mess.
I initially tried with an INI file but that got confusing too.  
This is what I have so far ...

Sub AutoNew()
Dim Order As String
Dim sView As String

Order = 
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", 
"CertificateNumber", "Order")

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

System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order") 
= Order

sView = ActiveWindow.View 'store the current view
With ActiveWindow
    .View = wdPrintView 'set the document view to print layout
    .ActivePane.View.SeekView = wdSeekCurrentPageHeader
    With Selection
        .WholeStory 'select any existing header text
        .Delete Unit:=wdCharacter, Count:=1 'and delete it
        .Font.Name = "Arial" 'Set the font characteristics
        .Font.Bold = True 'of the inserted header
        .Font.Italic = False 'if required
        .Font.Size = "16"
        .ParagraphFormat.Alignment = wdAlignParagraphRight

        'Insert the new header
        .TypeText Text:="Certificate No: " & Format(Order, "200#")
    End With
    .View.SeekView = wdSeekMainDocument 'Close the header view
    .View = sView 'and restore the initial view
    
Order = 
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")


ActiveDocument.SaveAs 
FileName:="S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems Isolations\Drier 2 
System Isolations" & Format(Order, "200#")

 End Sub


Sub AutoOpen()
Dim Order As String
Dim sView As String

Order = 
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")

'Create one and set the number to 1, otherwise increment the number

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

System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
Isolations\Drier 2 System Isolations Sequence.Txt", "InvoiceNumber", "Order") 
= Order
sView = ActiveWindow.View 'store the current view
With ActiveWindow
    .View = wdPrintView 'set the document view to print layout
    .ActivePane.View.SeekView = wdSeekCurrentPageHeader
    With Selection
        .WholeStory 'select any existing header text
        .Delete Unit:=wdCharacter, Count:=1 'and delete it
        .Font.Name = "Arial" 'Set the font characteristics
        .Font.Bold = True 'of the inserted header
        .Font.Italic = False 'if required
        .Font.Size = "16"
        .ParagraphFormat.Alignment = wdAlignParagraphRight

        'Insert the new header
        .TypeText Text:="Certificate No: " & Format(Order, "200#")
    End With
    .View.SeekView = wdSeekMainDocument 'Close the header view
    .View = sView 'and restore the initial view
    
Order = 
System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")


ActiveDocument.SaveAs 
FileName:="S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems Isolations\Drier 2 
System Isolations" & Format(Order, "200#")
End With
 End Sub
'
' AutoOpen Macro
' Macro created 23/01/2010 by Rachel Watson
'

Sub AutoClose() 'Recycles number if document unsaved.'
If ActiveDocument.Name Like "S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
Isolations\Drier 2 System Isolations*" Then
    If MsgBox("This Certificate has not been saved. Do you want to save 
before closing?", vbYesNo, "MacroSettings") = vbYes Then
         Application.Dialogs(wdDialogFileSaveAs).Show
    Else
        If MsgBox("The current number will be recycled.", vbOKCancel, 
"Recycle") = vbOK Then
        SettingsFile = Options.DefaultFilePath(wdStartupPath) & 
"\Settings.ini"
        End If
    ActiveDocument.Saved = True
    ActiveDocument.AttachedTemplate.Saved = True
    End If
    End If
    
End Sub
'
' AutoClose Macro
' Macro created 23/01/2010 by Rachel Watson

If there is anyway at all you are able to give me any help or advice it 
would be most appreciated.

Many thanks in advance,

rachgg4



0
Utf
1/23/2010 3:14:01 AM
word.newusers 801 articles. 0 followers. Follow

1 Replies
1114 Views

Similar Articles

[PageSpeed] 2

Please ignore this post as the question has now been answered in an earlier 
post. Thanks

"rachgg4" wrote:

> Once again, I am stuck in Macro world which is quickly consuming me :) It is 
> though, quite addictive and I am determined to win the fight I'm having with 
> my PC.
> I work for a company which uses network servers so the document needs to be 
> accessed by different people but not necessarily at the same time. We operate 
> Windows XP Word 2003.
> I am trying to create a document that will open with a sequential number, 
> but if the document is not used or opened accidentally then the number it has 
> generated needs to be recycled for auditing purposes. I seem to be able to 
> get the number to sequentially generate but the recycling of the number has 
> got me absolutely beat. I can’t for the life of me understand how to do it or 
> what I am doing wrong. 
> The other people who would be accessing the document are not very computer 
> literate and therefore I have tried to get the macro to AutoOpen so the 
> number is generated for them.
> I have tried using code that MVP's have provided other users of the forum 
> with, but when I try incorporating all different macros I just make a big 
> mess.
> I initially tried with an INI file but that got confusing too.  
> This is what I have so far ...
> 
> Sub AutoNew()
> Dim Order As String
> Dim sView As String
> 
> Order = 
> System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
> Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", 
> "CertificateNumber", "Order")
> 
> If Order = "" Then
> Order = 1
>  Else
> Order = Order + 1
> End If
> 
> System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
> Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order") 
> = Order
> 
> sView = ActiveWindow.View 'store the current view
> With ActiveWindow
>     .View = wdPrintView 'set the document view to print layout
>     .ActivePane.View.SeekView = wdSeekCurrentPageHeader
>     With Selection
>         .WholeStory 'select any existing header text
>         .Delete Unit:=wdCharacter, Count:=1 'and delete it
>         .Font.Name = "Arial" 'Set the font characteristics
>         .Font.Bold = True 'of the inserted header
>         .Font.Italic = False 'if required
>         .Font.Size = "16"
>         .ParagraphFormat.Alignment = wdAlignParagraphRight
> 
>         'Insert the new header
>         .TypeText Text:="Certificate No: " & Format(Order, "200#")
>     End With
>     .View.SeekView = wdSeekMainDocument 'Close the header view
>     .View = sView 'and restore the initial view
>     
> Order = 
> System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
> Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")
> 
> 
> ActiveDocument.SaveAs 
> FileName:="S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems Isolations\Drier 2 
> System Isolations" & Format(Order, "200#")
> 
>  End Sub
> 
> 
> Sub AutoOpen()
> Dim Order As String
> Dim sView As String
> 
> Order = 
> System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
> Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")
> 
> 'Create one and set the number to 1, otherwise increment the number
> 
> If Order = "" Then
> Order = 1
>  Else
> Order = Order + 1
> End If
> 
> System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
> Isolations\Drier 2 System Isolations Sequence.Txt", "InvoiceNumber", "Order") 
> = Order
> sView = ActiveWindow.View 'store the current view
> With ActiveWindow
>     .View = wdPrintView 'set the document view to print layout
>     .ActivePane.View.SeekView = wdSeekCurrentPageHeader
>     With Selection
>         .WholeStory 'select any existing header text
>         .Delete Unit:=wdCharacter, Count:=1 'and delete it
>         .Font.Name = "Arial" 'Set the font characteristics
>         .Font.Bold = True 'of the inserted header
>         .Font.Italic = False 'if required
>         .Font.Size = "16"
>         .ParagraphFormat.Alignment = wdAlignParagraphRight
> 
>         'Insert the new header
>         .TypeText Text:="Certificate No: " & Format(Order, "200#")
>     End With
>     .View.SeekView = wdSeekMainDocument 'Close the header view
>     .View = sView 'and restore the initial view
>     
> Order = 
> System.PrivateProfileString("S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
> Isolations\Drier 2 System Isolations Sequence.Txt", "MacroSettings", "Order")
> 
> 
> ActiveDocument.SaveAs 
> FileName:="S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems Isolations\Drier 2 
> System Isolations" & Format(Order, "200#")
> End With
>  End Sub
> '
> ' AutoOpen Macro
> ' Macro created 23/01/2010 by Rachel Watson
> '
> 
> Sub AutoClose() 'Recycles number if document unsaved.'
> If ActiveDocument.Name Like "S:\HLZ1-Hamilton\Morrinsville\MORRINS\Systems 
> Isolations\Drier 2 System Isolations*" Then
>     If MsgBox("This Certificate has not been saved. Do you want to save 
> before closing?", vbYesNo, "MacroSettings") = vbYes Then
>          Application.Dialogs(wdDialogFileSaveAs).Show
>     Else
>         If MsgBox("The current number will be recycled.", vbOKCancel, 
> "Recycle") = vbOK Then
>         SettingsFile = Options.DefaultFilePath(wdStartupPath) & 
> "\Settings.ini"
>         End If
>     ActiveDocument.Saved = True
>     ActiveDocument.AttachedTemplate.Saved = True
>     End If
>     End If
>     
> End Sub
> '
> ' AutoClose Macro
> ' Macro created 23/01/2010 by Rachel Watson
> 
> If there is anyway at all you are able to give me any help or advice it 
> would be most appreciated.
> 
> Many thanks in advance,
> 
> rachgg4
> 
> 
> 
0
Utf
1/25/2010 12:59:01 AM
Reply:

Similar Artilces:

number rounding in MS Excel
Hi, This may have been answered many times. In MS EXCEL is there a way that it calculates all numbers to 2 decimal digit accuracy instead of the 15 digit default? Thanks in advance for the answer. Hi You can set your decimal places in your cells as 2 and then check Precision As Displayed on the Tools / Options / Calculation page. Be careful though, it means what it says!! -- Andy. "mahusain" <abidh@bdnet.net> wrote in message news:ab59c6f6.0404200315.5196e8aa@posting.google.com... > Hi, > > This may have been answered many times. > > In MS EXCEL is ther...

Outlook 2003 News
I am trying to setup the news reader in Outlook 2003. I follow the directions but it won't stick when I drag news to go menu. Any ideas? To get the News command back, go back to the Programs tab in Control Panel | Internet Options and change the default newsreader to Outlook Express. If OE prompts you to make it your default newsreader the next time you launch it, clear the "Always perform this check..." box and then click the No button. You may need to reset the Menu Bar and/or restart Outlook and/or reboot your machine in order to complete the process. Not everyone is repor...

incorrect check / cheque number printing
When generating a cheque run, let’s say cheque 61, 62, 63 and 64, the information printed on cheque # 62 is actually cheque # 64 and vice versa. This does not happen every cheque run, but it does happen fairly often. I have not seen GP do this. What version and service pack of GP are you using? Are you 100% sure the check stock itself is not out of sequence? Do you have any customizations? -- Victoria Yudin Dynamics GP MVP Flexible Solutions, Inc. "Syed" <Syed@discussions.microsoft.com> wrote in message news:3B02ECEF-7436-4CF3-930E-AA4D2DFDF117@microsoft.com... ...

I want to unlock my word doc to make changes its protected
I am writing a word document the other night. I went to carry on with it tonight but found it has protected the document and won't let me continue writing or editing Word 2007? Assuming that you have activated Office, it seems your trial version of the application has expired. Time to pay the piper! -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> ...

Is Word in Office:Mac2008 the same as PC version?
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: intel If I learn how to use Word, will I be able to use the Windows or PC Version if I need to in the future for a job? The principles are largely the same; however, as of Office 2007 (Windows)/Office 2008 (Mac), there have been significant differences not only as far as the interface is concerned, but also the functionality in general. Word 2007 on Windows offers far more features than the Mac version, and, depending on your needs, this is the version you should get. However, to give you an adequate answer, we would need to kn...

Outlook 2003 #79
I nhave recently purchased Office Professional 2003. When using Outlook the send / receive function sometimes does not work and I need to log off the computer and log back on. All configurations are standard and the email servers have been verified by the ISP. Does anyone else have problems with the stability of Outlook 2003? ...

Help Required
Hi, Whenever I open Outlook 2003, I am getting a dialog box which displays the following message: Microsoft Office Outlook has encountered a problem and needs to close. We are sorry for the inconvenience When I click Debug it displays a message box with the following error message "The instruction at "0x3007e993" referenced memory at "0x0000000:. The memory could not be read" When I click No it Visual Studio JIT debugger pops up. I uninstalled and installed several times but still the problem persists. Is there any regsitry entry that I've to modify/delete? ...

Canadian Mergers 2003
I have Money 2003 which will not allow me to preform a stock merger in the Canadian format. Will upgrading to 2006 allow me to do this? In microsoft.public.money, giff42 wrote: >I have Money 2003 which will not allow me to preform a stock merger in the >Canadian format. Will upgrading to 2006 allow me to do this? Yes, with Deluxe there is a built-in function and above. It should be able to convert your Money 2003 file automatically. While there is not the built-in feature, here is how you could do it in Money 2003 Standard, do it if you did not hold both stocks involved in the merg...

Outlook 2003 with XP SP2
Hey guys, IS there an issue with outlook 2003 running on a XP machine with SP2. I am having connectivity problems. When I shut off the windows firewall, the outlook client connects. some help please. thanks, st I suggest that you add outlook2003 to the Windows Firewall exception list. Regards, -jack "stonefly" <shitij_T@hotmail.com> д����Ϣ����:OAoct1k5EHA.4028@TK2MSFTNGP15.phx.gbl... > Hey guys, > IS there an issue with outlook 2003 running on a XP machine with SP2. I > am having connectivity problems. When I shut off the windows firewall, the > outlo...

Filters in Excel 2003
I am using Filters in Excel 2003. Every cell in sheet B is linked to every cell in sheet A. That way I can alter data in B without corrupting the original data in A. I then highlight the cells in B that I want to assign a filter to and select Advanced Filter. I have no criteria so I do not set that. I click OK. I then select Filter again and this time select Auto Filter. Drop down arrows appear at the top of my columns. Great, no problems so far, I then select from the drop down list the criteria that I want to filter. Again no problems, my list filters correctly. But once I have do...

HELP Recovering addresses and email from Outlook 2003
I had some serious driver issues that required re-installing XP from disc. I did use the backup option and have a backup of all the old data. And of course had to reinstall Office 2003. Will third party software restore my old email and addresses or am I out of luck?? Thanks for the help texraid wrote: > I had some serious driver issues that required re-installing XP from > disc. I did use the backup option and have a backup of all the old > data. And of course had to reinstall Office 2003. > > Will third party software restore my old email and addresses or am I > out of lu...

Need Help with Deleting Empty Paragraphs in Word 2003
I have written the code below to delete all empty paragraphs at the end of a document and then place the cursor at the end of the last paragraph. It works fine as a stand alone sub in a new doc, but fails inside the real document that contains other code that manipulates several documents. The failure is that it will delete the last empty para, but then gets stuck looping inside the While...Wend because subsequent .Delete are not happening. So, the question is why would this work in one document, but then fail in another? n = 0 ...

Office 2003 Service Pack 3--subsequent problems opening Publisher
I run Publisher 2003 on Windows XP. On June 13, I updated my system with Office 2003 Service Pack 3 so that I could open Word documents with the file ext docx. Subsequent to the Service Pack 3 installation, whenever I open a Publisher file (which I created), I get the following message: "Publisher has detected a problem in the file you are trying to open. If you are certain that this file came from a trusted source and does not contain harmful information, click OK." What is causing this and is there a way to stop this pop-up message? All publications? Error message when you...

Using Access 2003 on client to see Sharepoint 2007
Testing a Sharepoint environment and I can easily manipulate and run the database from Access 2007, but when I try to use Access 2003 it wants me to save the database to a location. The Access 2003 has the compatiblity pack, but it seems to not work when I download it. So the question is using Sharepoint 2007 and posting the Access 2007 format to it, can a user go to the sharepoint site and use a 2003 Access database that has the compatibility pack and open without having to download it? -- Message posted via http://www.accessmonster.com Send check for $500.00 to: David A Jenn...

Outlook 2003 Out of Office Reminder RPC over HTTP
I have some remote office users that have Outlook 2003 configured using RPC over HTTP. They do not get the notice that pops up reminding them that their Out of Office is on when they open Outlook. Is there a way to get this to work? Thanks! Jeff ...

Phone Number Filtering
I am trying to sort special numbers in a long list of telephone numbers (7 digits). For example: a. Highlight yellow those numbers which have 3 consecutive digits (eg 2281555). b. Highlightt blue those numbers which have two double numbers (eg 4431122). c. Highlight green those numbers which are in a certain sequence (eg 2281234). I tried to use Left, Right and Mid formulas but the game becomes very complicated and hard to troubleshoot. Any better solution? The only effective way I know how to do this, is to use macros. Your samples a & b, are fairly simple to do. Sample c, could be d...

Fractions Number format
Is it possible to do a custom number format for cells such that fractions are displayed. I'm guessing not because there'd be a limit on what fractions you could display, but I would probably only be interested in showing a half as the little 1/2 (alt,0189 I think) rather than .5 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.478 / Virus Database: 275 - Release Date: 06/05/03 Lee There are a limited number of fractions that can be shown under Format>Cells>Fractions. Gord Dibben Excel MVP - XL97 SR2 & ...

Roman and Arabic numbers in SEQ
Running 2003 on XP. Got a doc that has SEQ numbering. The code is: ARTICLE{seq level0\h\r0}{seq level1\h\r0} etc. to level 7 and the last entry is {seq level0\r1\*ROMAN) This displays ARTICLE I The next level down is has this code: {seq level0\c\*ROMAN}.{seq level1\r1 \*arabic} This displays as : I.1, with numbers until article five displaying as V.1, V.2, etc. I want it to display as 1.1, 1.2, etc. I tried replacing the ROMAN with arabic, but it didn't change anything. I have spent hours trying to figure this out. Using reveal formating and styles, they are no styles...

Outlook 2007 Calendar -> Outlook 2003
In the past I could forward appointments and birthdays from one PC to another, if both PC's had Office 2003. I just tried forwarding a birthday from Outlook 2007 to Outlook 2003 and it doesn't work. I get the email in 2003. Open it, open the calendar item, then click on Save & Close. No error message. But it's not there. Neither in the current month or for next year. I forwarded it as a reoccurring item, that's the only way it will let you do that. Has anyone else been able to do this? Or, is this a backward compatibility issue? It's odd.... this works fine for...

PDA-Outlook 2003
I have a Jornada 540 and I try to sync to outlook 2003 using Activesync 3.7. I get the message Outlook is no longer installed. Reinstall MS Outlook. This happens on both Exchange and Outlook 2003 environment. Appreciate your help ...

Rounding Numbers #3
I have a list of values as below: 476.14 361.99 345.69 463.08 515.29 403.44 330.68 347.64 375.36 I would like to create a formula that rounds the values to the nearest 0.05 eg. Round 476.14 to 476.15, 361.99 to 362.00, 375.36 to 375.35 etc… Is there anyway that I can do this? Thanks, Jane. JaneC wrote: > I have a list of values as below: > 476.14 > 361.99 > 345.69 > 463.08 > 515.29 > 403.44 > 330.68 > 347.64 > 375.36 > I would like to create a formula that rounds the values > to the nearest 0.05 eg. Round 476.14 to 476.15, > 361.99 to 362.00, 375.36...

Invoice Numbers 10-27-07
We produce reports that are invoices.. The reports are really a group of compined reports if this matters... When we print the reports I would like to have printed consecutive invoice numbers. If possible I would like to have the number apprear as AS-00001, AS-00002 ect.. I am not really interested in storing the invoice numbers I just need them on the printed invoice as it is made of of groups of various data that is stored... Thank In Advance for you help. Bob If you just want a consequetive numbering on the report, all with an AS- prefix, see: Numbering Entries in a Report o...

Merge code issues with Publisher 2003
It seems whenever the data source is altered, the merge code fields have to be reinserted in the Publisher document. Is this normal? The data source starts in Excel and is then saved as a .txt file to retain number formatting on final merge. ...

opening a .docx with word 2004
Version: 2004 Operating System: Mac OS X 10.3 (Panther) How can I open a .docx attachment that has been sent to me with word 2004?? Can I convert it somehow at my end or does it have to be converted from the sender end? Thanks for any help... <cscs@sympatico.ca> wrote: > How can I open a .docx attachment that has been sent to me with word > 2004?? Can I convert it somehow at my end or does it have to be > converted from the sender end? Make sure that Office is up to date (or at least in version 11.5.0 - the altest version being 11.5.1) and install the XML convertrs you'...

Word 2004 overriding global prefs
Okay.. PMG5 running 10.4.6. I have a problem with the default page setup settings in two limited user accounts (my own, admin account, is fine). As I am in the UK, the global default paper size is set to A4. All applications respect this - bar Word. Every time it's fired up, and a new document selected, the paper size is always US Letter. This does NOT affect any other Office application. I have tried trashing prefs - I've even removed (using the supplied removal tool) and reinstalled Office. My mother uses Word extensively as she works at home a good deal. She wouldn't ...