Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim UpdateFile As Long Dim fso As Object Dim ts As Object Dim arr As Variant Dim Counter As Long Const FilePath As String = "w:\extract.txt" UpdateFile = MsgBox("Do you want to update the Extract file?", vbQuestion + vbYesNo, "Update") If UpdateFile = vbYes Then Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.CreateTextFile(FilePath, True) With ThisWorkbook.Worksheets("Extract") arr = Intersect(.UsedRange, .[a:a]).Value End With For Counter = 1 To UBound(arr, 1) ts.WriteLine arr(Counter, 1) Next ts.Close Set ts = Nothing Set fso = Nothing MsgBox "The file has been updated successfully." Else MsgBox "Text file not updated at this time." End If End Sub
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
18 Experts available now in Live!