How to close a previously open PDF file using VBA? - vba

I have a form in MS Access which is used to fill in some invoice details. Sometimes, the users will open the invoice to copy over the details. The invoice is always a PDF file. I want to make sure that as soon as the user is done with the form and closes it, the invoice PDF file is closed, too. Is there a way to do this using VBA?

Related

how to run Acrobat Create New PDF or Convert to PDF using VBA in Outlook desktop version

We have a process where the user saves an email as a .pdf file. I have developed a script that pulls the information for the filename from the email and prompts the user for additional necessary information.
What I can't figure out is how to then have my VBA script select the appropriate Acrobat command in the Ribbon or right-click menu. I've tried executemso, but the msoid is a non-specific "CustomControl". Specifically, the Acrobat add-in adds another tab to the Ribbon called "Acrobat" which then has the option Selected Messages (dropdown) with Create New PDF. Typically, my users just right click the email and choose "Convert to Adobe PDF". A third option would be to programmatically select File | Save as Adobe PDF.
So ideally a user could select an email message and run my VBA macro and that macro would then continue the process to the convert to pdf. Another thought I've had is to somehow watch for the event of creating a pdf and to run the macro and copy the programmatically-created filename to the clipboard.
There is no trivial way to execute custom ribbon controls from other add-ins. You may consider contacting add-in developers for any public API in the add-in which you could call directly. Also you may take a look at the Accessibility API.
Instead, you can try using the Word object model for saving email as a PDF file on the disk. The Inspector.WordEditor property returns the Microsoft Word Document Object Model of the message being displayed. The Document.ExportAsFixedFormat2 method allows saving a document which represents the message body in PDF or XPS format.

Is it possible to create fillable PDF from excel?

Currently, I have an excel file that upon launch it shows a userform where users can fill out a few text boxes/comboboxes and press create. Upon pressing create, it gathers stored data and creates a PDF that we send to vendors. It's essentially an invoice. The vendors that receive this PDF have to fill out a couple of lines and return it to us. Right now if they have no acrobat/reader experience, they're printing the PDF and then scanning and returning to us.
I want the vendors to be able to type in a few areas on the PDF and return it to us. My question is, can I create a fillable PDF from excel? Does anyone know how to do this using excel features or with VBA? Or any other method?
Thanks!
Brandon
Short Answer: Absolutely.
First you will start with a fillable pdf form. (you can create one using Adobe Acrobat or the older Adobe Designer)
It is my understanding, from your question that you would like to take some information, fill out a PDF, then send this to your client, to complete this.
Using VBA you can do all of this in one single button.
I created a step-by-step video on how to use the SendKeys method to achieve this.
Please see the detailed instructional YouTube video here: How to AUTOMATICALLY fill PDF forms using Microsoft Excel in 1 CLICK

Programmatical and application-based editing of an Excel file

Good evening,
I have the following problem to solve:
I want to add to an Excel file the contents of a bunch of user-generated .txt files. These files are generated throughout the day and sent over FTP to a folder, which is being constantly monitored by the program to see if there are new additions.
If the program finds new .txt files in it, it opens the Excel file which is to be edited, adds the info and then closes the Excel, saving the changes.
At the same time, users have to open these Excel files to check the new updated info and deal with it accordingly.
The program's execution is somewhat like this:
Infinite loop checking if the folder is empty or contains new .txt files.
If the folder is not empty (hence there is info to be added), it checks whether the Excel file is open or not.
If the Excel file is closed:
Opens it programmatically and adds the info to it.
Saves the Excel file and quits.
Backups the .txt to another folder in case there was some sort of error.
If the Excel file is open:
Keep checking until it is closed.
To check if the folder is empty or not I use: System.IO.Directory.EnumerateFileSystemEntries(path).Any()
To check if the Excel file is open I use:
System.IO.FileInfo(path) and a FileStream which, inside a Try-Catch clause, opens the FileInfo in the following mode: info.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None)
For the opening, editing and saving/closing of the Excel file I use Microsoft.Office.Interop.Excel.Application, [..].Workbook and [..].Worksheet.
The main problem comes when a user opens (through the normal Office Application) the Excel file in the middle of the addition process. I was hoping to find some sort of lockage of said file so the user cannot interrupt the editing process.
Any ideas on how to combine both types of opening/editing the Excel file?
Thank you so much in advanced.
TL;DR: How can I prevent, programmatically, a user from opening an Excel file while a program is editing that very Excel? Or at least, open another instance of it so the process is not interrupted?
PS: If any further code should be needed, I'll gladly post it :)
I think you need a better solution. It sounds like you are maxing out the capabilities of Excel. You would be better off, if possible, to use a database.

How do I hyperlink from a PDF file to a specific page in a PPT file

I have a PowerPoint 2010 file saved as a PowerPoint Macro-enabled show (.ppsm) file. I have a hyperlink on a particular page of the PPSM and I've linked it to a PDF file. Great, it all works.
Now I need to put a hyperlink in the PDF file that will jump me back to the specific page in the PPSM, but I can't seem to figure out how to do it. The information in another thread says to add "#15" (the page number) to the filename, but the link seems to put the entire file path. I also get an error that this is not a valid file name. I want to be able to just store the files together in the same directory and have them find each other with the file name, not the whole path.
All assistance gratefully accepted.
If you're running the slide show and link to a PDF file, the show is still running and sitting on the slide you linked from.
All you need to add to the PDF is a link that closes the PDF or possibly quits Acrobat/Reader altogether.
Open the PDF in Acrobat, add a link, choose Custom Link, click Next.
In Link Properties dialog box, go to the Actions tab
Select Action: Execute a menu item.
Click Add to get a list of available menu items, choose File, Close
or File, Exit.
If you need to return to some other page than the one you started on in PPT, it gets a bit trickier.

Saving the modified contents of a pdf

I've got a form that I downloaded, I'd like to prefill some content on the form (this is easy using cfpdfform).
Where it gets tricky is I would like to allow the user to modify the contents of that form, and then somehow have those modified contents accessible to me. I didnt build the source PDF so I dont know how to allow the user to "save" the new contents so they can be read.
Any ideas on where I might start on this one?
You can also use the cfpdfform tag to read/write data to a PDF file which has a form. The important thing is that the PDF document already have the form fields available, or that you add them.
I just recently completed a task where I had to have a user fill out a normal web form, and then create a filled version of an existing PDF document. It worked like a breeze!
I think that depending on what you are trying to accomplish, having the user fill out the data in a web form is less confusing than serving up a PDF and expecting them to save that to update a file on a remote server. Just my opinion, though.
http://www.cfquickdocs.com/cf8/?getDoc=cfpdfform#cfpdfform
It's possible for users to complete most PDF forms in Adobe Reader, but when user's try to save the changes they get a popup prompting them that the PDF cannot be saved and would need to upgrade to Adobe Acrobat to have this functionality.
Since Acrobat 7 (or possibly) 8 it's possible to create a form so that it can be completed and saved in reader. In Acrobat open your PDF, and select Advanced -> Enable usage right in reader from the menu. This will prompt you to save the form and then anyone using Adobe reader can complete it.
Once that's done you can open the form in ColdFusion, populate some of the fields and serve it up to the user. Once they fill it in, save it and get it back in ColdFusion you can read the contents using the PDF related tags.
Please note: It's currently not possible to set the "enable usage rights in reader" flag from ColdFusion, you need a copy of Adobe Acrobat or access to Adobe LifeCycle server to do this.
This document may help you:
http://www.adobe.com/education/instruction/teach/coldfusion/CF8-2_advanced_cf8_development_unit8.pdf