Hi Meg,
I hope you don't think I abandoned you. There has been a breakdown in the
transfer of posts from the NNTP gateway that most MVPs use and the Web
forums. The last transfer was on October 13, and it still isn't fixed.
This is a copy of the reply I posted to you on October 15, not realizing
that it wouldn't be visible to you.
Jay
---------------------------
This may get a bit deep if you don't have any experience with macros, but
I'll try to make it easier.
First, to answer the question in your other reply: The macro in the mvps.org
article uses a file "C:\Settings.txt" to store the current value of the
"order number". If the file doesn't exist, the macro will create it. The
name and folder location of the file aren't important -- you can name it as
you like and store it anywhere on the disk -- the only requirement is that
both references to it in the macro are exactly the same.
The forma field name can't be literally "Project Mgr Name" because spaces
aren't allowed. Look again in the Properties box of the field; it might be
that the spaces are just removed to make ProjectMgrName, or underscores are
used to make Project_Mgr_Name. In the following code sample, I've used the
former version.
The code in your macro should take account of a couple of possible snags.
The user might not have filled in the project manager name field yet, so
there wouldn't be anything to get initials from. If the field isn't blank,
it might have just one name -- maybe the person's surname -- instead of two.
Or it might have several, like the scientist Johannes van der Waals. I chose
to show how to extract one initial or at most two. In addition to the code
from the mvps.org article that gets and saves the Order number, you need
code like this:
Dim ProjMgrName As String
Dim ProjMgrInit As String
Dim LastSpacePos As Long
Dim TrackNum As String
ProjMgrName = _
Trim(ActiveDocument.FormFields("ProjectMgrName").Result)
If Len(ProjMgrName) = 0 Then
' field is empty
MsgBox "Please enter Project Manager name"
Exit Sub
End If
If InStr(ProjMgrName, " ") = 0 Then
' field has no spaces -- take only first letter
ProjMgrInit = Left(ProjMgrName, 1)
Else
' field has one or more spaces
' find location of last space, get second initial from next letter
LastSpacePos = InStrRev(ProjMgrName, " ")
ProjMgrInit = Left(ProjMgrName, 1) & _
Mid(ProjMgrName, LastSpacePos + 1, 1)
End If
TrackNum = UCase(ProjMgrInit) & _
Format(Now, "_MMMddyyyy_") & _
Format(Order, "0#")