Loading...
Quick Links

fileclose pjDoNotSave – but still getting prompt to save

Home Forums Discussion fileclose pjDoNotSave – but still getting prompt to save

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4933 Reply
    CommunityCommunity
    Keymaster
    Hi
    I have a custom toolbar which I want to remove when the user closes the file. I could do this by adding code to the auto_close event, but the problem is that the user might hit “Cancel”, then the toolbar is gone, but the file is still open. So I thought about simply replacing the “Do you want to close the file” dialog with one that looks exactly the same, but acts slightly different:
    – if user clicks “Yes”, then toolbar is removed, file is saved and closed
    – if user clicks “No”, then toolbar is removed, and file closed WITHOUT SAVING
    – if user clicks “Cancel”, nothing happens
    I wrote some code to do this, but the strange thing is that the statement “fileclose pjDoNotSave” seems to be ignored. After clicking “No”, the toolbar is removed, but I still get the standard prompt “Do you want to save the file” (after seeing my my own one). Any ideas what might be wrong with this statement? Thanks!
    Public Sub auto_close()
    Dim Selection As Integer
    Selection = MsgBox(“Do you want to save changes to “”” & ActiveProject.Name & “””?”, 35)
    Select Case Selection
    Case vbYes
    MsgBox “user selected yes” ‘this is just temporary, to check selection
    On Error Resume Next
    OrganizerDeleteItem Type:=pjToolbars, FileName:=”Global.mpt”, Name:=”STAR Toolbar”
    FileSave
    Case vbNo
    MsgBox “user selected no” ‘this is just temporary, to check selection
    On Error Resume Next
    OrganizerDeleteItem Type:=pjToolbars, FileName:=”Global.mpt”, Name:=”STAR Toolbar”
    fileclose pjDoNotSave
    Case vbCancel
    ‘      Do nothing
    End Select
    End Sub

    #6379 Reply
    CommunityCommunity
    Keymaster
    Martin,
    I see nothing wrong with your code.  I know this may sound strange, but on occasion, I have had to slow processes down so that a single "complex" or "time" consuming process can completely finish before executing the next step.  I have had to add a  Timer function following some commands to get them to process correctly.  It usually takes only one second to clear the way, but it works.
    Try inserting a Timer following the Tool bar deletion prior to FileClose.  Since I can’t see anything wrong with your code, I have no idea of anthing else to try.
    Here’s a trimmed down example from the VB Help screen.
    Dim PauseTime, Start
        PauseTime = 1    ' Set duration.
        Start = Timer    ' Set start time.
        Do While Timer < Start + PauseTime
            DoEvents    ' Yield to other processes.
        Loop
    
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: fileclose pjDoNotSave – but still getting prompt to save
Your information: