Closing a .pdf (1 Viewer)

aaronb50

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 2, 2014
Messages
185
How do I close a .pdf file using Access code?

There has got to be some simple line of code that will do this.

I know the location of the .pdf.

There has to be something like:

CloseFile(filePath.pdf)

I've looked and looked but cant seem to find the answer.
 

spikepl

Eledittingent Beliped
Local time
Today, 08:45
Joined
Nov 3, 2010
Messages
6,142
There isn't, because a pdf-reader launched from Access is a fire-and-forget story. It is a separate process.
 

aaronb50

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 2, 2014
Messages
185
Hmmmmmmmmm well if I cant close it then I need to figure something else out.

I have a front and back end program that stores a file structure path and has an easy to use GUI to find all of our .pdfs.

The admin places new records into the system when a new .pdf is issued.

Once the information has been filled out the Admin saves the new record and the program moves the .pdf from its current location to the new folder the program created in the file structure.

The problem is the Admin will have that .pdf open so they can use the information on it to fill out the new record. If they forget to close that .pdf before they save the record its not going to work correctly.

If I cant force that .pdf to close, what's another way to error trap this?
 

spikepl

Eledittingent Beliped
Local time
Today, 08:45
Joined
Nov 3, 2010
Messages
6,142
The problem is the Admin will have that .pdf open so they can use the information on it to fill out the new record. If they forget to close that .pdf before they save the record its not going to work correctly.

That sounds very strange. Explain how that comes about in details.

You can open/close pdf's if you have a PDF-editor, like, say, full adobe or foxit. I still do not quite see how closing the files reflects how data from it (presumably generated by access, so already available) is used.

Update:

Ok I've reread what you wrote and the PDF's seem foreign to access. You can still read a PDF, provided it is n't just scans, using various tricks, surely that is preferable to forcing a person to read something from a PDF and then typing it.
 
Last edited:

aaronb50

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 2, 2014
Messages
185
So we have hundreds of .pdf that we needed to have access to but filing them has been a nightmare for the person responsible for it.

I decided to take that mess, using access, and clean it all up and make it so people could actually find something.

Now, if someone is looking for a .pdf, they can go to the front end GUI and type in a word and find every .pdf we have with that word or phrase in the name or description. They have 4 different options for searching. Sooooooooo much faster then weeding through the old file structure.

When a new .pdf is created it is placed into a folder while it waits to be filed.

The old way, the admin would have to go into that folder and then figure out where to place that .pdf in the file structure, and then make new folders for it and place it in there.

I have automated that process. Now the admin just needs to fill out a few text boxes in the GUI and the Access program does everything for them. To include moving the .pdf from the waiting to be filed folder to its final resting place folder.

Now to fill out those text boxes, the admin needs information that is on the .pdf. So they have to open it to get it. If the admin forgets to close that .pdf before they save its record in the Access GUI, then the program will not be able to move it and the whole procedure will stop at that point.
 

spikepl

Eledittingent Beliped
Local time
Today, 08:45
Joined
Nov 3, 2010
Messages
6,142
Did you read my update? It is possible to read stuff from PDF's and perhaps extract what you need automatically.

And your process can be secured in a different way: you cannot move an open PDF - the move will fail and THAT will give you the error you can trap.
 

aaronb50

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 2, 2014
Messages
185
I can extract information from .pdfs? I will go down that road for a little bit and see if that will work for me. Thanks!!!

The problem with trapping the .pdf at the point is that the folder has already been created and the record added when I get to the point of moving it. If I trap it at that point, and let the admin know they need to close it and they do and then try to run it again I'm not sure what's going to happen when the program tries to do it all over again.

I could try to move it to a temp folder first before I do anything and if it fails stop the whole process.

Or I can just check to see if the folder exists and do nothing if it does.

Yeah that should work, I'll just check everything its doing to see if its been done already. That way if the error comes up and they need to run it again, additional information is not getting added places. That's probably a more proper way of coding anyway.

I'll go back and add that and then look into getting information from .pdfs. That would make life even better!!!

Thanks!!!!
 

spikepl

Eledittingent Beliped
Local time
Today, 08:45
Joined
Nov 3, 2010
Messages
6,142
To get info out of a PDF you need a command-line based reader. There is one called pdftotext.exe (part of XPDF suite) which is free, google it. It can extract text presenting some sort of layout or unformatted, simply spitting out everything from left to right. All this provided the PDFs do contain text, and not just picture scans.

You can launch the reading from within access, have to wait until it is finished (can be tricky) and then digest the resulting text file. IF your pdf's all have the same layout then you can do this. If layout differs, then it's a question of judgment.
 

aaronb50

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 2, 2014
Messages
185
I reread your post and this time noticed you said as long as the .pdf is not scanned.

Ugh......... they are all scanned in.

I don't think I will be able to use VBA in this instance to extract the information from the .pdf do to them being scanned in but I definitely see this being utilized elsewhere!!

I will work on getting pdftotext.exe approved so I can use it in the future.
 

spikepl

Eledittingent Beliped
Local time
Today, 08:45
Joined
Nov 3, 2010
Messages
6,142
I reread your post and this time noticed you said as long as the .pdf is not scanned.

Ugh......... they are all scanned in.

If the scans are OCR'ed before the PDF's are written then there is real text.

You can easily check this by opening one of them and seeing if you can select text in it using the cursor.
 

aaronb50

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 2, 2014
Messages
185
What is OCR'ed?

They start out as a word document then they are printed out to get stamps of approval then they are scanned in as a .pdf.
 

spikepl

Eledittingent Beliped
Local time
Today, 08:45
Joined
Nov 3, 2010
Messages
6,142
optical charater recognition. Many systems for document storage OCR faxes and other documents. check it.

It is a pity that you have a computer-generated file that then get destroyed into pictures. Is there no way to modify that proces? If these are SOPs under GMP then I 've seen all that carried out on Word documents and not PDF's, and one should negotiate with QA. (if you are not familiar with these abbreviations then I fired a wrong shot so just forget it). Besides, the hardcopies can be kept wherever, whereas the entire process with online copies could be done with Word docs.
 

aaronb50

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 2, 2014
Messages
185
We keep fighting the battle with QA and keep losing. They insist on getting their stamp on their.

But I like how you put that..........

"It is a pity that you have a computer-generated file that then get destroyed into pictures."

I'm going to go bring this up to my boss right now and let him know that yeah, its better with the new program, but if we don't turn it into a .pdf then life can be sooooooooo much better for us!

I think we can take this argument to QA and find some sort of agreement that satisfies them and keeps our documentation in a better format.
 

spikepl

Eledittingent Beliped
Local time
Today, 08:45
Joined
Nov 3, 2010
Messages
6,142
As plan B you could register the Word files - and extract data from them or ask the authors to submit the keywords necessary to categorise them into the respective proper folders.
 

aaronb50

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 2, 2014
Messages
185
Your a genius!!

Plan B is the answer.

We keep the original word file sitting right next to the .pdf so we can REV it in the future.

I can just read the information from the original Word Doc. No its not the stamped off document but it has the exact same information.

Boss said he gets it all the way but unless we can come up with another way to get QA approval on the documentation..........

But we don't need to do that.............. The original word doc is the answer.

Ok, I know how to read in .txt files, not sure about a .docx. I'm sure I can figure it out with a little help from Google.
 

spikepl

Eledittingent Beliped
Local time
Today, 08:45
Joined
Nov 3, 2010
Messages
6,142
Not to be a pain, but if you now have an electronic catalogue, then structuring the stuff into folders is redundant (because that is soemthing for human readers), and hence they could all get dumped into the same bucket, obviating the need for inspecting and cataloguing them :D

Now that would make QA freak, presumably:D
 

spikepl

Eledittingent Beliped
Local time
Today, 08:45
Joined
Nov 3, 2010
Messages
6,142
May I ask are these SOPS? Because I'm working on a small (commercial) Access application for managing training on SOPS, and I'll need a few trial customers (they'll get really good terms).
 

aaronb50

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 2, 2014
Messages
185
I have been screaming one bucket for a year and a half now.

We started out up to 10 folders deep. It was complete madness!!!!

Once I got the green light to fix it I was able to get that moved down to 3 deep. Boss is a believer, but he still likes the idea of having that human search capability if my program ever goes down.

I'm thinking this time next year, if the program is doing what I say its going to, he will have enough trust to let me put everything into one bucket. With just the three deep we are still looking at over 130 different paths. There is no real reason for this other then his piece of mind.

So in theory, I should be able to make access look into a folder, find a .docx and read in the information it needs to create the record on the Access backend and then file it and the .pdf all with the click of a button.

This thing is going to be awesome!!!
 

speakers_86

Registered User.
Local time
Today, 02:45
Joined
May 17, 2007
Messages
1,919
I'm glad he got his issue fixed, but couldn't he get a reference to the hWnd of the pdf and close it like that? Something like this?

I guess he could consider using using a pdf activex control or some kind of reference (if there is one), but I would strongly recommend not doing that.
 

aaronb50

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 2, 2014
Messages
185
SOPS - Standard Operating Procedures?

CM is tracking those.

I'm tracking our MSOs with the file part of this program. It also stores and lets our MEs create PALs which checks our equivalent part program I made two years ago and adds equivalent parts to the PAL as it prints. And it tracks ECP packages. Affectivity, what MSOs need to be done to complete them..... It has really grown into a monster.

This place was using stone and chisels when I showed up 2 and a half years ago. I've been pulling them out of the stone age one program at a time.
 

Users who are viewing this thread

Top Bottom