ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save as FIXED LENGTH (https://www.excelbanter.com/excel-programming/288743-save-fixed-length.html)

Anthony[_8_]

Save as FIXED LENGTH
 
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

Rob van Gelder[_4_]

Save as FIXED LENGTH
 
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


"Anthony" wrote in message
...
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





All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com