Results 1 to 3 of 3

Thread: Filestamp template is driving me crazy

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    1

    Filestamp template is driving me crazy

    Hello,

    I've inherited a Word template that is integrated with my firm's document management software (iManage). Whenever the document is saved (either by the user or autosave) the footer.dot kicks in and places a "filestamp" with the assigned document number in the footer. All of this works fine. The problem is when the footer.dot is finished running it returns focus back to the document at the insertion point and not the page taht was currently being viewed. Here is the problem code:

    VB Code:
    1. UserView = ActiveWindow.View.Type
    2.         Set thisdocument = ActiveDocument
    3.         With ActiveDocument.Bookmarks
    4.             .Add Range:=Selection.Range, Name:="dfwhere"
    5.         End With
    6.  
    7.         ViewState = ActiveWindow.View.ShowAll
    8.         ActiveWindow.View.ShowAll = True 'show all codes
    9.         For Each aSection In thisdocument.Sections
    10.             For Each aFooter In aSection.Footers
    11.                 If aFooter.Exists = True Then
    12.                     aFooter.Range.Fields.Update
    13.                 End If
    14.             Next aFooter
    15.         Next aSection
    16.  
    17.         Selection.GoTo What:=wdGoToBookmark, Name:="dfwhere"
    18.         Selection.Find.ClearFormatting
    19.         ActiveDocument.Bookmarks("dfwhere").Delete
    20.         ActiveWindow.View.ShowAll = ViewState
    21.         ActiveWindow.View.Type = UserView
    22.         Application.ScreenUpdating = True
    23.     End If
    24.  
    25.     ActiveWindow.View.Type = wdNormalView
    26.     ActiveWindow.View.Type = wdPrintView
    27.     ActiveWindow.View.Type = UserView
    28.     Application.ScreenUpdating = True
    29.    
    30. End Sub

    The question is, can I set the focus back to the document without having to go back to the insertion point? I basically just want it to work like a regular save.

    Please keep in mind that I'm a noob and I didn't write this code, I'm only trying to fix it.

    Thanks,

  2. #2
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: Filestamp template is driving me crazy

    is this all of the code? or just a section?
    if you fail to plan, you plan to fail

  3. #3
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: Filestamp template is driving me crazy

    you could use the following code to get the current page and section before carrying out the code you posted..(code from MS knowledge base, not my own)

    then go back to the page when it is complete.

    VB Code:
    1. Public Sub rPageSectionNumber()
    2.       Dim sCurPage As String
    3.       Dim sCurSection as String
    4.       ' Obtain page number.
    5.       sCurPage = Selection.Information(wdActiveEndPageNumber)
    6.       ' Obtain section number.
    7.       sCurSection = Selection.Information(wdActiveEndSectionNumber)
    8.       ' Display results.
    9.       MsgBox "Page " & sCurPage & ": " & "Section " & sCurSection
    10.    End Sub
    if you fail to plan, you plan to fail

Posting Permissions

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



Click Here to Expand Forum to Full Width