We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
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
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.