DeeJay*123
New Member
- Joined
- Dec 10, 2012
- Messages
- 21
Hello - I have, with the expert assistance from a user here, the following code. I need to, however strip the text file it creates of the " marks Excel has decided to add in before I close the file created. Does anyone know how to accomplish this by possibly adding a line of code in?
I think I would be able to accomplish this step if I were recording the macro but I still don't know how to translate my recorded code over to the written code. It doesn't seem to cut/paste over seamlessly and me, not knowing VBA, am at a loss.
Sub CreateCodeandSave()
'
' CreateCodeandSave Macro
'
' Keyboard Shortcut: Ctrl+Shift+E
'
Application.DisplayAlerts = False
Sheets("CONCATS AND TIME VALUES").Range("H4").Value = Sheets("CONCATS AND TIME VALUES").Range("G4").Value
Sheets("CONCATS AND TIME VALUES").Range("H6").Value = Sheets("CONCATS AND TIME VALUES").Range("B6").Value
Sheets("CONCATS AND TIME VALUES").Range("H6").NumberFormat = "[$-409]m/d/yy h:mm AM/PM;@"
Sheets("CONCATS AND TIME VALUES").Range("H8").Value = Sheets("CONCATS AND TIME VALUES").Range("G8").Value
Sheets("CONCATS AND TIME VALUES").Range("H12").Value = Sheets("CONCATS AND TIME VALUES").Range("G12").Value
'Sets variable that holds the new filename
Dim NewFileName As String
NewFileName = Sheets("Result").Range("A7").Value
Sheets("Result").Range("A1:A2").Copy
Workbooks.Add
ActiveWorkbook.ActiveSheet.Paste Destination:=Worksheets(1).Range("A1:A2")
Application.CutCopyMode = False
'Turns the copied cells into values
Range("A1:A2").Value = Range("A1:A2").Value
ChDir "Z:\ISGDemandManagement"
ActiveWorkbook.SaveAs Filename:="Z:\ISGDemandManagement\" & NewFileName & ".txt", FileFormat:=xlText, CreateBackup:=False
'I BELIEVE HERE I NEED TO STRIP THE TEXT FILE JUST CREATED OF THE " MARKS, & SAVE AGAIN
ActiveWindow.Close
Sheets("Input and Execute").Select
Application.DisplayAlerts = True
MsgBox "Done!"
End Sub
I think I would be able to accomplish this step if I were recording the macro but I still don't know how to translate my recorded code over to the written code. It doesn't seem to cut/paste over seamlessly and me, not knowing VBA, am at a loss.
Sub CreateCodeandSave()
'
' CreateCodeandSave Macro
'
' Keyboard Shortcut: Ctrl+Shift+E
'
Application.DisplayAlerts = False
Sheets("CONCATS AND TIME VALUES").Range("H4").Value = Sheets("CONCATS AND TIME VALUES").Range("G4").Value
Sheets("CONCATS AND TIME VALUES").Range("H6").Value = Sheets("CONCATS AND TIME VALUES").Range("B6").Value
Sheets("CONCATS AND TIME VALUES").Range("H6").NumberFormat = "[$-409]m/d/yy h:mm AM/PM;@"
Sheets("CONCATS AND TIME VALUES").Range("H8").Value = Sheets("CONCATS AND TIME VALUES").Range("G8").Value
Sheets("CONCATS AND TIME VALUES").Range("H12").Value = Sheets("CONCATS AND TIME VALUES").Range("G12").Value
'Sets variable that holds the new filename
Dim NewFileName As String
NewFileName = Sheets("Result").Range("A7").Value
Sheets("Result").Range("A1:A2").Copy
Workbooks.Add
ActiveWorkbook.ActiveSheet.Paste Destination:=Worksheets(1).Range("A1:A2")
Application.CutCopyMode = False
'Turns the copied cells into values
Range("A1:A2").Value = Range("A1:A2").Value
ChDir "Z:\ISGDemandManagement"
ActiveWorkbook.SaveAs Filename:="Z:\ISGDemandManagement\" & NewFileName & ".txt", FileFormat:=xlText, CreateBackup:=False
'I BELIEVE HERE I NEED TO STRIP THE TEXT FILE JUST CREATED OF THE " MARKS, & SAVE AGAIN
ActiveWindow.Close
Sheets("Input and Execute").Select
Application.DisplayAlerts = True
MsgBox "Done!"
End Sub