Mar 22, 2012

Copy a pdf table into excel

In the last couple of weeks, I was searching for some evidence in the literature related to resource usage in telemonitoring. And part of this job consisted on copy pasting table from PDF(I recommend using Foxit reader instead of Adobe reader ) to word. And believe me it’s not that as easy as you might think. In some cases, MS word can do most the work by converting the text into a table ( option 1), but in some cases the formatting of the original data is so distorted that even word cannot sort it. That why, I have written the following VBA code (option 2) to be added to excel (It could be useful in certain circumstances, and easily tweaked according to the original data).

Option 1 : use word convert text to table option :

Option 2
: Add this vba script replacing the space by comma ( from the end of the line)

Function TestingRev(inputStr As String) As String

Dim nbCol As Integer
nbCol = 4

Dim revInputStr As String
revInputStr = StrReverse(inputStr)

Dim ret As String

ret = Replace(revInputStr, " ", ";", 1, nbCol - 1)

TestingRev = StrReverse(ret)

End Function

- Copy paste the result in notepad and save it as *.csv file
- Open the csv file in excel and save it as

No comments: