11 Replies Latest reply: Dec 19, 2013 1:47 AM by Gysbert Wassenaar RSS

    Export to text file with fixed length data

    Vamshi Tataipelli



      I have written a macro to export the straight table in a qvw to a flat file (.txt) file and was able to specify the delimiter i wish to.


      The macro which i used is as follows:


      sub Export

      Dim docProp

      set docProp = ActiveDocument.GetProperties


      Dim tmpFile  'used to create relative filepaths

      tmpFile = docProp.MyWorkingDirectory


      tmpFile = tmpFile & "External Data Sources\OperationalReportsOutput\"


      set obj = ActiveDocument.GetSheetObject("CH01")

      obj.Export tmpFile & "Activity" & ".txt",";"


      end sub


      Now i have to change the output data to a fixed length datatype. It means for suppose, i have 3 fields

      Name  Address              Phonenumber

      Sam    Greenville,USA    2159627856

      Vizard Charlotte, USA    2527255632


      If i gave a fixed length of 20 to the fields:and i specify no delimiter,

      the output should look like

      Sam                 Greenville,USA      2139627856

      Vizard               Charlotte,USA       2527255632


      So every record in the text file should end at the same point.


      Any ideas!