Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple question: Insert DocsOpen doc number?

Status
Not open for further replies.

OrphanAnnie23

Technical User
Jun 16, 2005
6
US
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.
 
Try inserting this code into your NewMacros Module:

Code:
Option Explicit
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!!!
 
Dear sritzel:

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!
 
The version might be a bit trickier. We were extracting ours from the full path of the document. Here's how we're doing it:

Code:
Dim Version$

...

Version$ = Trim(Str(Val(Mid(path$, InStr(1, path$, ".") - 3, 2))))

Let me know if that works.

-Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top