In this event, after the line 'Sheets("PREQUEST").Range("Q1").Value = "Yes"' If NotePad…
- User
In this event, after the line 'Sheets("PREQUEST").Range("Q1").Value = "Yes"' If NotePad 'filelist.txt' is open, I want to close it without any prompts.
Private Sub Worksheet_Activate() Application.EnableEvents = False If Me.Range("R1").Value = "Yes" Then GoTo Process End If
Call Module58.ListFilesInNotepad Application.Wait (Now + TimeValue("0:00:01"))
Dim answer As VbMsgBoxResult answer = MsgBox("Q U O T E S P A G E" & vbCrLf & vbCrLf & _ "YES for a Pending Quote to start in QUOTES" & vbCrLf & vbCrLf & _ "If there is NO Pending Quote for this prequest" & vbCrLf & _ "NO for Purchase Request to be started in PREQUEST" & vbCrLf & _ "details will be auto recorded to QUOTES", vbYesNo + vbQuestion, "NEW PREQUEST") If answer = vbNo Then Sheets("PREQUEST").Range("Q1").Value = "Yes" Sheets("PREQUEST").Activate Exit Sub End If Process: Application.EnableEvents = True End Sub
- Assistant
To close the NotePad filelist.txt without any prompts, you can use the following code:
Private Sub Worksheet_Activate() Application.EnableEvents = False If Me.Range("R1").Value = "Yes" Then GoTo Process End If Call Module58.ListFilesInNotepad Application.Wait (Now + TimeValue("0:00:01")) ' Check if the filelist.txt is open Dim filesList As Object Set filesList = CreateObject("System.Collections.ArrayList") Dim objWindow As Object ' Loop through all open windows For Each objWindow In CreateObject("Shell.Application").Windows If InStr(1, LCase(objWindow.Document.Folder.Self.Path), "filelist.txt") > 0 Then ' Close the window without saving objWindow.Document.Saved = True objWindow.Document.Close End If Next objWindow Dim answer As VbMsgBoxResult answer = MsgBox("Q U O T E S P A G E" & vbCrLf & vbCrLf & _ "YES for a Pending Quote to start in QUOTES" & vbCrLf & vbCrLf & _ "If there is NO Pending Quote for this prequest" & vbCrLf & _ "NO for Purchase Request to be started in PREQUEST" & vbCrLf & _ "details will be auto recorded to QUOTES", vbYesNo + vbQuestion, "NEW PREQUEST") If answer = vbNo Then Sheets("PREQUEST").Range("Q1").Value = "Yes" Sheets("PREQUEST").Activate Exit Sub End If Process: Application.EnableEvents = True End Sub