Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Simple question: Insert DocsOpen doc number?

Simple question: Insert DocsOpen doc number?

Simple question: Insert DocsOpen doc number?

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.

RE: Simple question: Insert DocsOpen doc number?

Try inserting this code into your NewMacros Module:


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!!!

RE: Simple question: Insert DocsOpen doc number?

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!

RE: Simple question: Insert DocsOpen doc number?

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:


Dim Version$


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

Let me know if that works.  


RE: Simple question: Insert DocsOpen doc number?


This is a really challenging way to learn VB....

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close