View Single Post
 
Old 06-13-2019, 12:56 AM
ghost5 ghost5 is offline Windows 10 Office 2016
Novice
 
Join Date: Jun 2019
Posts: 4
ghost5 is on a distinguished road
Default Automatically Convert Text to Table with unique character as deliminator

Hi,

I have a piece of software that outputs a report in text format which is a mixture of words and tables. The report uses spaces to make the report look correct and ordered in notepad but when this is copied over to our final report and center aligned it looks like a mess.

I have been using the record macro feature to remove the extra spaces throughout the report and to add a unique character '£' where the deliminator for the tables needs to be.

I can now go through the document and manually select the tables and use the convert text to table feature which works well but I want to automate this process using VBA.

I am thinking of having word VBA to loop through the document, find all sentences / lines that have £ in them, select the line and then convert text to table for that individual line but I cannot find anything on the web like this so I don't know where to start.

I cannot select the whole document and covert it due to it being a mixture of text and tables and some tables having 3 columns and others 7.

This is a sample of the text with £ in it which has the first 5 lines as either text or paragraphs then the rest of the data as a table

Code:
Adjusted Observations and Residuals
===================================

Adjusted Distance Observations (Meters)

From£To£Distance£Residual£StdErr£StdRes£File:Line
SEL01£SEL06£294.3875£-0.0003£0.0015£0.2£1:31
SEL01£SEL02£15.3749£-0.0003£0.0014£0.2£1:32
SEL07£SEL05£307.6708£-0.0001£0.0015£0.0£1:35
SEL07£SEL06£309.3499£-0.0006£0.0015£0.4£1:36
SEL05£SEL07£307.6708£0.0001£0.0015£0.1£1:39
SEL05£SEL04£314.7247£-0.0004£0.0015£0.3£1:40
SEL04£SEL05£314.7247£0.0006£0.0015£0.4£1:43
SEL04£SEL03£52.4068£-0.0001£0.0014£0.1£1:44
SEL03£SEL04£52.3564£0.0006£0.0014£0.4£1:47
SEL03£SEL02£33.3976£0.0005£0.0014£0.4£1:48
Can someone help me to get started with this?

Thanks
Reply With Quote