Simple question: Insert DocsOpen doc number?
Simple question: Insert DocsOpen doc number?
(OP)
Sorry to bother you with a simple question, but -- How can I insert a Docs Open file number (not the entire ODMA path, just the assigned file number, without version number) into a Word Doc? Word's autotext will insert the entire ODMA file path with number, but that's not acceptable to my admin people. Macros aren't enabled on our network, altho I might get a dispensation in this case if anyone has a macro we could use. I just don't know how to capture that info.
Using Docs Open 4.0.0 build 61, Windows NT, Word 2002 and Citrix.
Thanks for any suggestions or referrals.
Using Docs Open 4.0.0 build 61, Windows NT, Word 2002 and Citrix.
Thanks for any suggestions or referrals.
RE: Simple question: Insert DocsOpen doc number?
CODE
Private Declare Function DOCSGetProfileInfo Lib "DOCSAP32" (ByVal openFileID$, ByVal item$, ByVal itemBuffer$, ByVal bufferLen As Integer) As Long
'=======================================================================
' Macro to insert Docs Number only
'=======================================================================
Sub InsertDocNumber()
Dim DocNumber$
Dim openfilename$
openfilename$ = ActiveDocument.FullName
DocNumber$ = GetProfileInfo$(openfilename$, "DOCNUMBER")
Selection.TypeText DocNumber$
End Sub
Public Function GetProfileInfo$(openFileID$, item$)
Dim itemBuffer As String
Dim rc As Integer
itemBuffer = String(512, " ")
rc = DOCSGetProfileInfo(openFileID$, item$, itemBuffer, 512)
If rc = 0 Then
itemBuffer$ = ""
End If
itemBuffer$ = Trim(itemBuffer$)
GetProfileInfo$ = Mid(itemBuffer$, 1, Len(itemBuffer$) - 1)
End Function
Let me know if it works!!!
RE: Simple question: Insert DocsOpen doc number?
Thanks. My attempted solutions all depended on using an existing Word field, converting to text and then editing the text. Yours is much cleaner and more elegant, and works beautifully.
Would it be pushing if I asked if you could give me code to recover the version number also? I'm only just learning to "read" VBA (the hard way) and don't know where to find the name of that property to call in the macro.
Either way, thanks again -- that was a big help!
RE: Simple question: Insert DocsOpen doc number?
CODE
...
Version$ = Trim(Str(Val(Mid(path$, InStr(1, path$, ".") - 3, 2))))
Let me know if that works.
-Steve
RE: Simple question: Insert DocsOpen doc number?
This is a really challenging way to learn VB....