Is there a way to connect PDF document and Excel sheet? - vba

I want to know whether there is a way to connect a Fillable PDF document and excel sheet. I know this question may be little open ended. But I have been searching a lot to find out if there is a way to do it, without much success. My requirement is I want to connect a Fillable PDF with an excel sheet, so that whenever we fill the PDF document, the excel sheet automatically populates.
I am not sure whether this is possible or not. If it is possible, can anybody tell me a way to do that? So that I can search on it and figure it out?

In the olden days, it was possible to set up a direct connection, using ODBC (and the ADBC object in the PDF). This has, however, been abandoned a few Acrobat versions ago.
The most direct connection would be based on SOAP, but it requires Acrobat; it does not work with Reader.
All other ways of communicating with a database/spreadsheet are asynchronous, meaning that you have to initiate the process from your form.
You can use the form to create a tab-delimited file which you then can import into your back end, or you can submit data to a server which then communicates with the back end. Or, as it has already been stated, you can control Acrobat using VB (or Applescript), and get data out by this way.

Related

Google App Scripts: Parsing PDFs successful, but data in 'fillable fields' gets lost

I'm building a tool in Google App Scripts that compares an original pdf form (with blank fillable fields - no OCR should be necessary) to the completed field. Both documents are stored in the same google drive.
My general strategy is as follows:
Parse blank pdf form into an array of rows
Parse completed pdf form into an array of rows
Compare to find differences (the values that got filled in).
I'm using mogsdad's Apps Script pdfToText utility, which was successfully able to parse the blank form perfectly. The problem I've run into is that when I try to parse a completed form, all of the data in the fillable fields gets lost.
I've established that the loss of information happens at the following line in the code:
var gdocFile = Drive.Files.insert(resource, pdfFile, insertOpts);
When the pdf data is saved as a gdoc, any data in a fillable field goes missing.
I have established that if I open the pdf in DocHub or similar and save a copy (that is no longer editable), the data can be parsed.
My two plans of attack are either:
Find a way to parse a pdf with fillable forms, or
Find a way to 'flatten' the fillable forms out of a pdf so that it can be parsed (I'm not sure of the terminology around this).
Does anybody have any advice on where to look for a way to accomplish either option (or any other ideas)?
I feel like my problems with this are due to missing some knowledge about how PDFs work, rather than a javascript issue.
Thanks

#Command([EditCopy]) in LotusScript

I can't find a way to copy selected documents to buffer using standard classes in LotusScript.
Is it possible to do it?
#Command([EditCopy])
The problem with command/formula - is more difficult to debug/log errors etc, so I wish to re-write action to LotusScript if possible.
I can make a solution via Java and then wrap it into LS2J, but it looks to complicated for such simple operation.
You can't copy selected documents to clipboard with standard LotusScript Notes classes.
NotesUiDocument.Copy() doesn't help you neither as it copies only selected parts of an open document.
I would stay with #Command([EditCopy]). If it's really worth it to move the formula code to LotusScript I would separate #Command([EditCopy]) in an agent and call it from your new LotusScript code.
But, the question is, what is the goal to copy selected documents to clipboard? It will be a Notes Client specific kind of clipboard content. You can only use it in Notes Client itself to copy the documents into the same or another database. So, why not use "normal" LotusScript methods to copy documents like NotesDocument.CopyToDatabase or NotesDocument.CopyAllItems?

VB.net text -> Excel conversion (with extensive formatting required after conversion)

I'm creating a program in VB.net that does the following:
At a high level I receive a file in email, put the attachment in a monitored folder, import the text file to excel, format the excel, and then email the excel file to a list of recipients.
Here is my plan:
Completed: Outlook VBA to monitor all incoming email for specific message. Once message is received drop attached .txt file in a specific network folder.
Completed: (VB.net) Monitor folder, when text file is added begin processing
Not Complete: (VB.net) Import text file to Excel
Not Complete: (VB.net) Format Excel Text file. (add in a row of data, format column headers with color/size, add some blank columns, add data validation to some of the blank columns that allow drop down selections)
Completed: (VB.net) Save file.
Completed: (VB.net) Send file to list of recipients.
Obviously the items above that are not complete are the bulk of the work, but I wanted to get some advice on what some of you think would be the best way to approach something like this. The import and formatting of the file are causing me some problems because I just can't decide what would be the most efficient way to do this.
What I've thought of so far:
The way stated above. Import to excel -> format
Having a template excel that contains all of the formatting already done for me and attempting to transition the data to this document (no clue if/how I can do this). Is it even feasible? Have the template already created and then import the text file to a new excel file, then transition that data to the excel template?
Something I thought about, in terms of formatting the document, was to record a macro of me doing all of the formatting that I'm going to need and then attempt to convert that macro into my vb.net code, but I'm not sure if that will work. I will need to verify that the text file comes in the EXACT format every time correct?
I really appreciate any advice/suggestions that anyone is willing to give.
You will want to use http://epplus.codeplex.com/
It allows you to create an Excel file from scratch, without having to start Excel itself. Automating Excel will make the process slow and it lacks robustness (Excel process can hang or not close properly).
In addition, using a .Net library allows you to run it on a server or so where no Excel is installed. (Next step would be to inspect the mailbox via POP, IMAP or the Exchange API, so that part doesn't have to be run on a client machine either)
http://msdn.microsoft.com/en-us/library/kh3965hw(v=vs.100).aspx
You can also just use the Interops from MS to interact with Excel, Outlook, Word, etc. They're not difficult at all to use. I'm not familiar with CodePlex, so that may be a better route or an easier one. I just wanted to provide you with an alternative.
With Microsoft Office 2010 Interops you can not generate Office files from .net applications anymore.
You can manipulate data from existing Excel files so you need templates(your 4th point). Then Excel allows you to query some databases. You may be able to simulate one with your folder, otherwise I suggest to convert your .txt files into some databases. (3rd point)
If you do use an older version, you can crate your Excel files by loading them into an instance of Excel and manipulating them as you wish.
By the way I supposed your attached files would have some sort of format.
If you want to manipulate Excel files, I can recommand you the NPOI library found on CodePlex. It has several advantages over OLE-automation:
NPOI is not dependent on a specific Excel version.
Excel (or any other Office component) need not to be installed.
It is faster.
It works with both .XLS and .XLSX files.
We are using a third party software called excel writer. May not be what you are looking for becauseit needs to be license, but it is very fast and the clients does not have to wait for a chart or a data output. Because we have that tool, have not try anything else.

How to read changes in excel file into vb.net application

I have an excel file which is auto generated by third party software..and its readonly file and its data constantly keep changing online.
now i want to use or read that data in my vb.net application whenever its changes take place in excel file automatically.
please help me..
Cody's right. No question, but I'm guessing you're looking to do something along these lines.
First, you'll need to pull down a copy of that XLS file (sounds like it's online at a website somewhere). To do that, you'll need to perform a pretty normal HTTP get or use whatever API the website provides to pull the file down.
Save the file locally, then open it and read it using EXCEL AUTOMATION. Just google excel automation for loads of examples of opening a worksheet file, reading cell values, and closing the file.
There's other options too such as the OpenXML api from Microsoft to allow you to read the contents of XLSX files directly without using excel automation, so that may be a possibility. not enough in the original post to know which would work best for you.

VB - Automated Excel in Visual Studio 2010 - Selection Changed Question

I am currently writing an utility that takes two different sets of data from an excel document and sends it to two different web services. Each set of data has it's own button that sends the data to the web service. When the a button is clicked, the corresponding web service then returns data depending on the input values.
What I am trying to do is so that this utility can be distrobuted and used by a wide variety of people. What they are going to do is they are going to be synchronizing there particular cells of their own excel document to the corresponding cell in my utility. Using simple excel formulas. For example:
c:\temp\[book1.xls]sheet1'!a1
Now what I am trying to do is automatically "click" the button, or update, on my utility when the user links their cell to its corresponding cell on my utility.
I have tried the selection change event on my page. But it doesn't actually process until my utility is active, or clicked on.
Is there a way to make my utility automatically update? It would be especially awesome if somehow it did this while my utility was closed. So when the user opens it it is already filled with their information, and the outputs are correct.
The requirements:
you need to guarantee that when a user is using excel your app can collect the data. Your app may not be running at the time. You need the Worksheet_SelectionChange() event to fire automatically not just when your app is active.
Solution:
Basically in order to guarantee that the Worksheet_SelectionChange() is running all the time, and in order to guarantee that whenever the user opens an instance of excel you are able to collect and process the data/formulas entered into the particular target range address you need to wire up the selectionchange event inside of a VB.NET Excel COM Addin. There are several ways to do this, but since your using VB.NET your best off using the newest approach which is building a VSTO COM Addin.
There are numerous other questons available on how to best build a VSTO addin (some in C# some in VB.NET but all this information is exactly the same for both, just different syntax).
So you will need two projects. Your existing one, plus a Excel VSTO addin (which you can also do in VB.NET).
Now inside the selectionchange event you should make sure that your code handles the target range correctly; ie. make sure you check for non-contigious groups of ranges with a selection... A1:B1;D2:E2 and copy the data to your app. You may consider using a format such as xml to serialise the latest data from excel so that if your app is not open at the time, it can deserialise and read back the data stored for it the next time it is opened. I guess it really depends how your handling the data (i.e. is it for loading into a datagrid?) and whether you are going to do further processing and store it somewhere else later (in which case maybe you can put it straight into a database from the addin in excel).