• Which Event Occur When Saving (W2000 SR-1)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Which Event Occur When Saving (W2000 SR-1)

    Author
    Topic
    #362565

    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

    Viewing 1 reply thread
    Author
    Replies
    • #550849

      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.

      • #550885

        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

    • #550970

      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(wdDocumentsPath)) 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

      • #551099

        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

    Viewing 1 reply thread
    Reply To: Which Event Occur When Saving (W2000 SR-1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: