Excel document with auto increment

Hi all.
Now I've got a problem, which I think you, who knows Excel, can help me to solve.

I have one .xls-document which will be used as a template for invoices and then I need to have a invoice number which is auto increment. I've solved that part by adding a new module in the Visual Basic editor:
Sub auto_open()
With ActiveSheet.Range("A1")
.Value = .Value + 1
End With
ActiveSheet.Select
End Sub

It works perfect and gives it a new invoice number for each time you open the file. The big problem comes next when you save the file, then the number will increase for each time the document is opened.

The solution I've come up with is something like this:
- One excel document with the invoice number
- One template which get the number from the document containing the invoice number
- Then when it's saved it will break all connections to other excel documents so that it stops with the auto increment.

Does anyone have any other, and easier solution than this one? In other case, how do I got the solution above to work?... Don't even know how I import data from another excel document, it only becomes some kind of odc-file which never works.

[1212 byte] By [JesperLofgren] at [2007-12-22]
# 1

Hi Jesper

Actually, no, this isn't the correct place to ask your question. This forum is specific for questions about Visual Studio TOOLS for Office, not for questions about Office. The TOOLS are a special add-in for Visual Studio and are .NET Framework specific. Nothing to do with VBA or an auto_open procedure. Please ask your question in the excel.programming newsgroup, where you'll find the technical experts for working with the Excel application

http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.excel.programming&lang=en&cr=US

CindyMeister at 2007-8-30 > top of Msdn Tech,Visual Studio Tools for Office,Visual Studio Tools for Office...