Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Which Event Occur When Saving (W2000 SR-1)

    I would like to know how I can make a procedure start when I use File/Save or File/Save as.

    I need to run a procedure which updates a text box in a dialog box(form) and a bookmark in the document.
    The procedure is inside a form in which the file name is displayed among other text and parameters.

    Have looked for any events for this purpose but in vain.

    Thanks for any help!

    Regards
    Bj

  2. #2
    Star Lounger
    Join Date
    Sep 2001
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Which Event Occur When Saving (W2000 SR-1)

    Did you try to use the "DocumentBeforeSave" event yet? I have to admit, I never used this event myself, but it is documented in the Microsoft Visual Basic Help.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: Which Event Occur When Saving (W2000 SR-1)

    No, not yet, thought it might be special ones for such an event. I had also hoped that some could give me an example of such code using "DocumentBeforeSave" event.

    I will continue to work on it when spare time comes around, may be later to night. In the meantime I hope for answers.

    Thanks for responding.

    Regards
    Bj

  4. #4
    Star Lounger
    Join Date
    Sep 2001
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Which Event Occur When Saving (W2000 SR-1)

    Hello Bj

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Which Event Occur When Saving (W2000 SR-1)

    I find that trapping the Word dialogs can be quite refreshing. Maybe this would work instead of coding up a nearby event.

    Sub FileSave
    'Do your thing here
    'Then, when you are done, make sure you pop up the
    'Inadequate, but easily accessed Word dialog:
    With Dialog(wdDialogsFileSave)
    .show
    End with
    End sub

    and

    Sub FileSaveAs
    'Same idea
    End sub

    Here's a somewhat involved example:

    Sub SaveAsDialog(strFileName As String)
    Dim dlg As Dialog
    Dim strFile As String
    Dim strDir As String

    Set dlg = Dialogs(wdDialogFileSaveAs)
    With dlg
    Do While True
    .Name = strFileName
    ' If fFolderExists(vFolderName) Then
    ' ChangeFileOpenDirectory (vFolderName)
    ' ElseIf fFolderExists(Options.DefaultFilePath(wdDocumentsP ath)) Then
    ' ChangeFileOpenDirectory (Options.DefaultFilePath(wdDocumentsPath))
    ' End If
    Select Case .Display
    Case -2 'Close
    Exit Sub
    Case -1 'ok
    vFileName = .Name
    If InStr(vFileName, " ") <> 0 Then 'Filename has spaces
    vFileName = Mid$(.Name, 2, Len(.Name) - 2)
    End If
    Call WriteProtectOff
    'Update all fields before save
    Call UpdateFields
    Call UpdateFootNotes
    Call ConvertDateToSaveDate

    'Set the current user as the owner as this is NOT the original document
    Call DocVarAssign("DocOwner", vFullName)
    If vDelegates <> "" Then
    Call DocVarAssign("DocDelegates", vDelegates)
    End If

    ActiveDocument.AttachedTemplate.Saved = True
    .Execute
    .Update
    Call UpdateFields 'Make the changes from Date To SaveDate visible
    .Execute
    Exit Do
    'End If
    Case 0 'Cancel
    Exit Do
    End Select
    Loop
    End With
    Set dlg = Nothing
    End Sub
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #6
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: Which Event Occur When Saving (W2000 SR-1)

    Thanks Kevin,

    I will "study" your code and see if I can use this. I'm just an amateur and have some difficulties in understanding all code. (May be I should not involme me into coding at all, but it is fun!)

    Thanks again.

    regards
    Bj

Posting Permissions

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