The invoice code is word code and it needs tweaked to work in outlook - but what i thought i needed to do to tweak it, didn't work.
See
Outlook Addins, Macros & Tips - VBOffice for one option. (Michael's Send macros are listed at
Outlook VBA Macros - VBOffice )
Sequential numbers, stored in registry:
Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim sAppName As String
Dim sSection As String
Dim sKey As String
Dim lRegValue As Long
Dim lFormValue As Long
Dim iDefault As Integer
sAppName = "Word 2000"
sSection = "Invoices"
sKey = "Current Invoice Number"
' The default starting number.
iDefault = 101
' Get stored registry value, if any.
lRegValue = GetSetting(sAppName, sSection, sKey, iDefault)
' If the result is zero, set to default value.
If lRegValue < 100 Then lRegValue = iDefault
' Increment and update invoice number.
SaveSetting sAppName, sSection, sKey, lRegValue + 1
Errhandler:
If Err <> 0 Then
MsgBox Err.Description
End If
Item.Subject = CStr(lRegValue) & Item.Subject
End Sub
for random numbers, try this:
Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
intHighNumber = 10000
intLowNumber = 1
Randomize
intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)
Item.Subject = intNumber & Item.Subject
End Sub
This one does 5 random characters (alphanumberic)
Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Item.Subject = GetRandom(5) & Item.Subject ' change 5 to another number for longer key
End Sub
Function GetRandom(Count)
Randomize
For i = 1 To Count
If (Int((1 - 0 + 1) * Rnd + 0)) Then
GetRandom = GetRandom & Chr(Int((90 - 65 + 1) * Rnd + 65))
Else
GetRandom = GetRandom & Chr(Int((57 - 48 + 1) * Rnd + 48))
End If
Next
End Function