Results 1 to 7 of 7

Thread: [RESOLVED] Close template if not doc not saved

  1. #1

    Thread Starter
    New Member String-0's Avatar
    Join Date
    Mar 2006
    Posts
    11

    Resolved [RESOLVED] Close template if not doc not saved


    I made a template in WORD
    But what am trying to do now is that
    When the template is open should be a wdDialogFileSaveAs should be started
    But when the user clicks on cancel the template should be closed and not be used anymore

    i thought of solving it like that

    MsgBox "SAVE befor you start … "

    activedocument.Saved = False
    CommandBars.FindControl(ID:=3).Execute

    If activedocument.Saved Then
    ' MsgBox "The document was saved."
    ' If MsgBox("you dont want to save the doc? ?", vbYesNo + vbQuestion, SAVING) = vbNo Then
    ' activedocument.Close
    '
    activedocument.Close
    RecentFiles(1).Open
    yesNo = yes
    Else
    MsgBox "somting "



    But i always get Error or it doesn’t work good ..
    Help .. any tips ?

  2. #2
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Close template if not doc not saved

    Add the following code in a module in your template:
    VB Code:
    1. Sub AutoOpen()
    2.     Dim dlgSaveAs As Dialog
    3.     Set dlgSaveAs = Dialogs(wdDialogFileSaveAs)
    4.     With dlgSaveAs
    5. BeginSave:
    6.         If Not .Display = -1 Then
    7.             If MsgBox("you dont want to save the doc? ?", vbYesNo + vbQuestion) = vbNo Then
    8.                 ActiveDocument.Close
    9.             Else
    10.                 GoTo BeginSave
    11.             End If
    12.         Else
    13.             .Format = wdFormatDocument
    14.             .Execute
    15.         End If
    16.     End With
    17. End Sub
    CS

  3. #3

    Thread Starter
    New Member String-0's Avatar
    Join Date
    Mar 2006
    Posts
    11

    Talking Re: Close template if not doc not saved







    it worked
    thxxxxxxxxxxxxxxxxx u r the best !
    am comming to you forum everyday

  4. #4
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Close template if not doc not saved

    Please mark the thread "RESOLVED" if you got an answer to your questions.
    Last edited by cssriraman; Mar 9th, 2006 at 11:07 AM.
    CS

  5. #5

    Thread Starter
    New Member String-0's Avatar
    Join Date
    Mar 2006
    Posts
    11

    Re: Close template if not doc not saved

    how where what ??

  6. #6
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Close template if not doc not saved

    Quote Originally Posted by String-0
    how where what ??
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    CS

  7. #7

    Thread Starter
    New Member String-0's Avatar
    Join Date
    Mar 2006
    Posts
    11

    Re: [RESOLVED] Close template if not doc not saved

    ok sorry guys ;; i just did it ..


    thx alot again

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