Microsoft Excel - I need help in to open,copy,remane pdf file in Excel vba codes
Asked By muzamil ahmed on 05-Jul-16 04:25 AM
I have a folder contain with 50 pdf files with different name... Basically i have to open each pdf file and need to copy invoice # from PDF file and need to rename the pdf file with invoice #... So any can help me to code the Excel vba code to run an macro to auto open pdf file copy selected text and rename it....
Please help me in this at the eariest..
Thanks you
Harry Boughen replied to muzamil ahmed on 05-Jul-16 07:17 PM
Hello Ahmed,
I think what you want to do is possible but it will be a bit tricky.
I have not tried any of this so you will have to experiment in a safe place and by combining codes you should be able to automate the process if the various bits work.
First you need to read the pdf file into a spreadsheet using the method outlined on this page.
http://www.vbaexpress.com/kb/getarticle.php?kb_id=1101
Assuming that this works and you can get your invoice number from a cell you could save the worksheet as a pdf by using the method on this page.
http://powerspreadsheets.com/save-excel-file-pdf-vba/
If this method is not satisfactory then you might be able to modify the code given by Harry Flashman on this page to just rename the files. Just be advised that at this stage you have to include the whole path in the new name or the file is saved in the directory with the excel file.
http://www.mrexcel.com/forum/excel-questions/423149-using-excel-visual-basic-applications-rename-files-directory.html
Hope this helps
Harry