Hello,
I currently use the below code to find and select a .txt file. The code then formats that text file from comma seperated and copies this information to an excel spreadsheet (which is seperated by cells instead of commas).
What I would like to do is to select an excel spread sheet, convert the information (which is seperated by cells) and copy this information into a text file with the same format as the text files that were originally converted above (i.e. comma seperated).
Any help would be appreciated.
Thanks.
I currently use the below code to find and select a .txt file. The code then formats that text file from comma seperated and copies this information to an excel spreadsheet (which is seperated by cells instead of commas).
Code:
Dim Filter As String, Title As String, Msg As String
Dim FilterIndex As Integer
Dim FilenameClient As Variant
Dim Wkb2 As Workbook
Const PTH = "S:\FMS\FMS - Foreign Exchange\Global Link - Finished Deals\PrimeCo Upload\"
Dim strFile As String
strFile = Dir(PTH & "*.*")
If Len(strFile) > 0 Then
Do
Kill PTH & strFile
strFile = Dir
Loop While Len(strFile) > 0
'MsgBox "Current File Deleted"
'Else
'MsgBox "No File Found"
End If
' File filters
Filter = "Text Files (Finish_mel.ncssell*.txt),[Finish_mel.ncssell*.txt],"
'"All Files (*.*),*.*"
'"Excel Files (*.xls),*.xls," & _
'Default filter *.*
FilterIndex = 1
'Set Dialog Caption
Title = "Select Mel Side"
'Select Start Drive & Path
ChDrive ("S")
ChDir ("S:\FMS\FMS - Foreign Exchange\Global Link - Finished Deals")
With Application
' Set File Name Array to selected Files (allow multiple) False = Single
FilenameClient = .GetOpenFileName(Filter, FilterIndex, Title, , False)
Workbooks.OpenText FileName:=FilenameClient _
, Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 4), Array(13, 1), Array(14, 1), Array(15 _
, 4), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _
Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1)), TrailingMinusNumbers:=True
Columns("L:L").ColumnWidth = 10.29
Set Wkb2 = ActiveWorkbook
Wkb2.ActiveSheet.UsedRange.Copy Workbooks("PrimeCo.xlsm").Worksheets("Mel").Range("A1")
YesNo = MsgBox("Is this the Correct MEL Side File?", vbYesNo + vbQuestion, "Click on Yes or No")
Select Case YesNo
Case vbYes
Windows("PrimeCo.xlsm").Activate
'Sheets("PrimeCo Home").Select
Case vbNo
Windows("PrimeCo.xlsm").Activate
Sheets("Mel").Cells.Clear
Windows("PrimeCo.xlsm").Activate
Sheets("PrimeCo Home").Select
End Select
End With
Wkb2.Close savechanges:=False
'End Select
End Sub
What I would like to do is to select an excel spread sheet, convert the information (which is seperated by cells) and copy this information into a text file with the same format as the text files that were originally converted above (i.e. comma seperated).
Any help would be appreciated.
Thanks.