Hi guys,
I'm only new to creating macros but I am trying to make one which can open a number of files save them as txt files and then close them. Everytime it asks me if I want to save the changes to the txt file and I can't workout how to stop this happening. If anyone could help it would be very much appreciated!
Code:
Sub SaveAsTextFile()
Dim filenames As Variant
' set the array to a variable and the True is for multi-select
filenames = Application.GetOpenFilename(, , , , True)
counter = 1
' ubound determines how many items in the array
While counter <= UBound(filenames)
'Opens the selected files
Workbooks.Open filenames(counter)
Dim strDocName As String
Dim intPos As Integer
'Find position of extension in file name
strDocName = ActiveWorkbook.Name
intPos = InStrRev(strDocName, ".")
'Strip off extension and add ".txt" extension
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".txt"
'Save file with new extension
ActiveWorkbook.saveas Filename:= _
strDocName, FileFormat:= _
xlText, CreateBackup:=False
ActiveWorkbook.Close
'increment counter
counter = counter + 1
Wend
End Sub