Save as FIXED LENGTH

  • Thread starter Thread starter Anthony
  • Start date Start date
A

Anthony

Is it possible to define the length of a field in excel
then save it as a FIXED LENGTH formatted text file?
eg. --Currently happening--
Hello,Black,Apple,Computer
--What i want to happen--
Hello ,Black ,Apple ,Computer
 
Anthony,

Sub test()
Const cFileName = "C:\T\myfile.txt"
Dim intFreeFile As Integer
Dim strVar1 As String, strVar2 As String
Dim strVar3 As String, strVar4 As String

strVar1 = "Hello": strVar2 = "Black"
strVar3 = "Apple": strVar4 = "Computer"

intFreeFile = FreeFile
Open cFileName For Output As #intFreeFile
Print #intFreeFile, strVar1; Tab(9); ","; strVar2; Tab(16); ",";
strVar3; Tab(28); ","; strVar4
Close #intFreeFile
End Sub

Rob
 
Back
Top