"<br />"
.Thanks to Luke for the answer.
"<br />"
.'WIA' is not declared. It may be inaccessible due to its protection level.
That should have been easy enough to fix, just reference the Microsoft Windows Image Acquisition Library v2.0. The problem was that it wasn't there. (Or at least I couldn't see it.) I finally figured out that Gary didn't have version 2.0 on his XP computer and had to get a copy and register it separately. When the program was installed, it registered the wiaaut.dll file to the one Gary included in the program files instead of the system32 folder. As soon as I uninstalled the program, there went my reference to "WIA". To fix the problem, I had to re-register the copy that was still in the system32 folder. After I rebuilt the program, we also had to re-register wiaaut.dll on all the computers the program was installed on. regsvr32 wiaaut.dll
(hit enter)
' Reference to Acrobat application
Dim gApp As Acrobat.CAcroApp
'IAC objects
Dim gPdDoc As Acrobat.CAcroPDDoc
Dim formApp As AFORMAUTLib.AFormApp
Dim acroForm As AFORMAUTLib.Fields = Nothing
Dim field As AFORMAUTLib.Field
'Initialize Acrobat by creating App object
gApp = CreateObject("AcroExch.App")
' Initialize the PDF object
gPdDoc = CreateObject("AcroExch.PDDoc")
' Open an example PDF file in acrobat
If gPdDoc.Open("C:\example.pdf") Then
' I'm still not sure what all of this does
s = gPdDoc.GetFileName
gPdDoc.OpenAVDoc(s)
formApp = CreateObject("AFormAut.App")
' Get a reference to the fields from the form
acroForm = formApp.Fields
' Get a reference to the particular checkbox field
' This uses the data structure of the form to find the form,
' then page, then fieldname
field = acroForm.Item("form1[0].#subform[0].Checkbox3[0]")
' Set the checkmark to "on"
field.Value = "1"
' Set the checkmark to "off"
field.Value = "0"
Else
MsgBox("Failed to open")
End If
Flat PDF – A PDF with no XFA stream and no non-signature elements. Basically there are no fields in the document. It is important to note that a “Flat” PDF may still have some layers, such as the comment layer. In this case the flatness refers to the lack of data fields.
Static PDF – A PDF which contains an XFA stream and the form layout does not change. Static forms may be interactive (a user can still fill in fields). If a dynamic XDP is rendered with LiveCycle Forms with the Render At Client option set to “No” then the resulting PDF is no longer dynamic – it is now static and behaves like any other static PDF.
Dynamic PDF – Dynamic PDFs allow the layout of the form to be altered either through user interaction or through script. An example is a form that adds subforms based on a user input. If a static XDP is rendered with LiveCycle Forms with the Render At Client option set to “Yes” then the resulting PDF is no longer static – it is now dynamic and behaves like any other dynamic PDF.
Acroform – A non-XFA based PDF form, usually created directly in Adobe Acrobat (as opposed to using LiveCycle Designer).When I tried running the following code
formApp = CreateObject("AFormAut.App")
acroForm = formApp.Fields
If the form was saved in Adobe LiveCycle as Static, acroForm would contain all of the fields from the form, however if it was saved as dynamic, no error was thrown, but acroForm would not contain any fields. Both static and dynamic forms use XFA streams (Adobe's flavor of xml) to render the pages, but the underlying structure and the way the form is displayed can be dramatically changed in a dynamic form. It would appear that my code was unable to access the fields, because the structure of the fields on a dynamic form can change after it is rendered. A field that was on page 1 to start with could end up on page 10 after the client using the form made some selections that altered the form or even problematically before the form was first rendered. "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." --Brian KernighanIn other words, if you barely understood the code you were writing when you wrote it, you are going to have an extremely hard time trying to figure out issues with that code further down the road. The iServer notification program I rewrote to alert users of readings of temperature and humidity that were outside of excepted ranges is a good example. My supervisor had me rewrite the program, taking out the threading that was used because he was concerned the threading might be causing some of the problems. I did that and it mostly works. (I still have an issue with socket connections timing out.) I did, however, quickly realize why Gary used threads. Connecting to a socket is very time intensive and it locks the program while it sits there waiting for the socket response. Each iServer socket connection takes 10-15 seconds and with 32 iServers that equates to about 6-8 minutes for the whole process. Gary's other program which monitors the iServers can get the readings for all the iServers in about 10-15 seconds. In other words, Gary is able to use threads to query all the iServers at the same time and keep his program from becoming unresponsive. My program works, but I was concerned that it becoming unresponsive while it was waiting for all the socket connections would eventually cause problems. So I found an example on the Microsoft developer network for using an Asynchronous Client Socket. It looked to be straight forward, but when I tried to implement the code, I got no benefits. My code was taking just as long and was still locking up the application. Well..., in order to make asynchronous calls to the socket, the example is using threading. Obviously, I didn't understand enough about threading and where I needed to use it in my programming. I believe the issue was that I was using the threads in my server class, when I needed to be using the threads outside the server class in the main class. The thread needs to allow each server to try and make a connection with the socket and get the needed readings. While one server is waiting for a response, the thread needs to sleep and give a chance for the next server to make a connection. That can't be done inside the server class. It has to be done from the outside. Once again grasshopper, you still have much to learn!