Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Sep 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    question about Word macro (Word 2003)

    Hello...

    I have have a macro in Word that was given to me by another company and not being the best coder in the world I don't know how to change it to work the way I would like. Currently the macro is written to collect the document ID, version number and client number from where it stored online and insert the above into the document's footer.

    What I need it to do is the same, except the document info needs to be inserted where the user has placed their curser. This is like the standard Filename & Path command already in Word. Any help, tips or pointers would be gladly appreciated!

    Thanks!
    Chancer

    Public Sub UpdateFooter()
    Dim docLen As Long
    Dim tSearch As Find, docID As String, idStr As String
    Dim verNum As Integer
    Dim idStart As Long
    Dim Client As String
    Dim Matter As String
    Dim ndActDoc As New ndActiveDoc, docEnd As Range
    Dim today As Date
    Dim Cabinet As String

    'Build the ID string
    docID = RetrieveDocAttribute(ndActDoc, "ID")

    If Len(docID) < 14 Then
    'Document is not stored in NetDocuments
    MsgBox ("Not a NetDocuments Document")
    Exit Sub
    End If
    verNum = RetrieveDocAttribute(ndActDoc, "VERNUM")
    Client = RetrieveDocAttribute(ndActDoc, "Client")
    Matter = RetrieveDocAttribute(ndActDoc, "Matter")
    ' Cabinet = "M&S"
    Cabinet = RetrieveDocAttribute(ndActDoc, "CABINET")
    today = Date

    idStr = Cabinet & ":" & docID & "v" & verNum & "|" & Client & "-" & Matter & "|" & today

    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
    ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View.Type = wdOutlineView Then
    ActiveWindow.ActivePane.View.Type = wdPrintView
    End If

    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

    If Selection.HeaderFooter.IsHeader = True Then
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    End If
    Selection.WholeStory
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.TypeText idStr

    Selection.WholeStory
    Selection.Font.name = "Arial"
    Selection.Font.Size = 8

    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: question about Word macro (Word 2003)

    You can simply replace this section of code
    <code><div style="width: 100%; background-color: #FFFFFF;">
    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
    ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View.Type = wdOutlineView Then
    ActiveWindow.ActivePane.View.Type = wdPrintView
    End If

    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

    If Selection.HeaderFooter.IsHeader = True Then
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    End If
    Selection.WholeStory
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.TypeText idStr

    Selection.WholeStory
    Selection.Font.name = "Arial"
    Selection.Font.Size = 8

    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    </code></div hiblock>
    with
    <code>
    <span style="background-color: #FFFFFF;">Selection.TypeText idStr</span hiwhite>
    </code>
    StuartR

  3. #3
    New Lounger
    Join Date
    Sep 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: question about Word macro (Word 2003)

    THANK YOU StuartR!
    It works like a charm. I was pulling out my hair over this one...at least the grey ones. Thanks again.

    Chancer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •