Creating macro converting docx files into pdf

Hello,
I'm trying to create a macro that automatically find all .docx and .xlsx files into selected folder and convert them into PDFs files. I already make something but it converts too much (for example gifs files). Can you help me in that?
Thanks in advance for your help.
Robert

Run this macro from Word:
Sub ConvertWord2PDF()
Dim strFolder As String
Dim strFile As String
Dim doc As Document
Dim lngPos As Long
Dim strPDFName As String
With Application.FileDialog(4)
If .Show Then
strFolder = .SelectedItems(1)
Else
MsgBox "You didn't specify a folder!", vbExclamation
Exit Sub
End If
End With
If Right(strFolder, 1) <> "\" Then
strFolder = strFolder & "\"
End If
Application.ScreenUpdating = False
strFile = Dir(strFolder & "*.doc*")
Do While strFile <> ""
Set doc = Documents.Open(FileName:=strFolder & strFile, _
AddToRecentFiles:=False)
lngPos = InStrRev(strFile, ".")
strPDFName = Left(strFile, lngPos) & "pdf"
doc.ExportAsFixedFormat OutputFileName:=strFolder & strPDFName, _
ExportFormat:=wdExportFormatPDF
doc.Close SaveChanges:=True
strFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
and this one from Excel:
Sub ConvertExcel2PDF()
Dim strFolder As String
Dim strFile As String
Dim wbk As Workbook
Dim lngPos As Long
Dim strPDFName As String
With Application.FileDialog(4)
If .Show Then
strFolder = .SelectedItems(1)
Else
MsgBox "You didn't specify a folder!", vbExclamation
Exit Sub
End If
End With
If Right(strFolder, 1) <> "\" Then
strFolder = strFolder & "\"
End If
Application.ScreenUpdating = False
strFile = Dir(strFolder & "*.xls*")
Do While strFile <> ""
Set wbk = Workbooks.Open(Filename:=strFolder & strFile)
lngPos = InStrRev(strFile, ".")
strPDFName = Left(strFile, lngPos) & "pdf"
wbk.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFolder & strPDFName
wbk.Close SaveChanges:=True
strFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
Regards, Hans Vogelaar (http://www.eileenslounge.com)

Similar Messages

  • Acrobat XI Pro successfully installed, but it failed in converting word files into PDF, why?

    I just installed Adobe XI Pro through the download assistant, it looks the installation went well, but when I tried to convert word files into PDF (tried many times), it failed. Anyone has the same problems, any solutions?

    Please reply with more information - what your operating system is, do you have Office installed, and what exactly is happening. Is there an error message, does the application crash, and from where are you starting the conversion (using Word and PDFMaker, using Acrobat's Create button, or batch processing).

  • Convert XML file into PDF file

    <b>XML to PDF</b>i want to Convert XML file into PDF file pl. any one can suggests API's

    Hi,
    There are many ways to convert XML files to PDFs through java.
    One of the easiest way is by using iText.jar which have classes for conversion.
    The following are the required steps
    1. Create a document object for the XML file ( Using DOM or SAX parser).
    2. Parse the xml document and extract the content to write in PDF.
    3.Create a itext Document object.
    4.Get a PdfWriter instance for the PDF file.
    5.Write in the pdf the extracted text using the document object.
    Refer <a href="http://itextdocs.lowagie.com/examples/com/lowagie/examples/general/HelloWorld.java">here</a> for a simple pdf writer example.
    Refer <a href="http://java.sun.com/developer/codesamples/xml.html">here</a> for examples of XML Parsers.
    Regards,
    Uma

  • About converting a file into PDF

    why an error always occur when converting a file into pdf ?

    oceanblue1968 wrote:
    why an error always occur when converting a file into pdf ?
    Why is, when I just missed my train, the next train always late? (sigh)

  • Converting PST files into PDF's & the recipient can't print

    I am having the following issue with Adobe: I am converting PST files into PDF's and the recipient can view the information, but they cannot print. Actually, some information such as whether there is an attachment is displayed in the printout, but none of the actual text appears. I do not see any security settings at this end that would be causing this, but I have been assured that there is nothing on the recipients either. The same thing was happening when I sent it to a colleague here in the office.

    I discovered the problem and solution. Often PST's contain damaged text. It is not easy to deal with the damaged text. It is more efficient to have the recipient print the file as an image.Select the print tab, go to advanced, select print as image. I got the information by looking through the more specific information on the Adobe site.

  • Converting Framemaker files into PDF progaramatically using publishing server

    Hi All
    Background:
    We are going for upgrade of  Frame maker 8 which is on unix system  to FM 10 or 11. We are using Framemaker mainly for renditions, i.e to convert the fm documents to PDF. To convert fm document to PDF we are using the below mentioned command line utility available in FM 8.(on unix). /opt/app/frame8.0/bin/fmprint -i -p Sample.fm.fmtpl Sample.fm Currently the the fm file which need to converted to PDF and the FM 8(installed) are available on the same unix system ,so we were able to initiate/use the command line utility of FM 8. The rendition of the FM to PDF is On -Demand.( We are not running any batch activities/ bulk renditions).We are rendering the document as soon as the document  is available.
    Requirement:
    As we are going to  upgrade the FM to newer versions which would be installed on the Windows machine as Frame maker 10 or 11 will not support unix plat form, so can you please let us know which option is better to use i.e we want to convert fm file to PDF using java program without any manual intevention using publishing server/client version.
    can any one help us as it is very urgent for us.
    please let us know the ways to do and links for helpful documents .
    thank you very much for your help in advance!!\
    Best reagrds
    Ramesh babu

    Hi Ramesh...
    Another alternative (if you need more control over the doument creation) is to use Leximation's AutoFM ..
        http://leximation.com/tools/info/autofm.php
    Cheers,
    ...scott
    Scott Prentice
    Leximation, Inc.
    www.leximation.com

  • Convert iPhoto file into pdf file

    Need to convert iPhoto files in pdf format to send as email attachment to a recipient who requires it in this format.  How do I do it?

    There might be a quicker way, but an alternative is:
    - Locate the photo(s) in Finder
    - Open them in Preview
    - File > Print (or CMD + P)
    - In the bottom left there should be a drop-down menu for PDFs.  You can then choose to save it as a PDF, or email it as a PDF attachment.
    This works for single and multiple photos.  Bear in mind that they will save at the original resolution, so if you want the file to be smaller, make all the changes you want to in iPhoto then locate them in Finder.
    Hope this helps.

  • Error in converting docx file to pdf

    My docx file of 91MB fails to convert to pdf format when using the adobe PDFprogram.  This also happened before I changed from a doc to the docx.

    This forum is about the Cloud as a delivery process, not about using individual programs
    If you start at the Forums Index http://forums.adobe.com/index.jspa
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says ALL FORUMS) to open the drop down list and scroll

  • Convert xml file into .pdf and .html

    hi all,
    can any one let me know how can i show xml file values into pdf and html by using java
    thanks in advance

    sreeks27 wrote:
    hi all,
    can any one let me know how can i show xml file values into pdf and html by using java
    thanks in advanceTake a look at Apache FOP:
    http://xmlgraphics.apache.org/fop/

  • Converting word file into PDF creates exclamation marks

    Hi,
    I have Word 2007 and Acrobat 8.1.7 (OS: Windows XP). When creating PDFs in Word i get exclamation marks at the end of a header, footer and body itself. I tried rebuilding font cache but that didn't help. I also uninstalled all Adobe components and installed them anew - didn't do anything either. Have no other ideas. Please help...
    Thanks!

    The key is the print preview. If they are there, then they are being produced by WORD, not Acrobat. At that point, the Adobe PDF printer driver has not come into play other than providing WORD printer metric information. Check your settins in WORD. You should also be getting the same result if you just printed to paper or any other printer.

  • Converting Illustrator File into PDF/X-1A File?

    Can someone provide me with step-by-step instructions on how to convert a CS2 Illustrator file (mac) into a PDF/X-1A File that would be suitable for hi-res printing in a major publication? My AI file contains mac fonts (which can either be outlined or kept as is) and one CMYK image. All colors are already in CYMK mode in my AI file.
    Thanks!
    Tuan

    You don't need to outline fonts for a PDF file. Choose File > Save As. Choose Format: Adobe PDF (pdf). Choose the PDF/X-1a:2001 PDF Preset.
    But it's always a good idea to check with the printer for special requirements, if possible.

  • Converting files into pdf format in java

    Hi all,
    How can we convert a file into PDF format in java?My application does the
    file upload, and I need the files to be converted into PDF format.
    The uploaded file can be of any type. How can I do this?
    Please give me some help.
    Thanks and regards,
    Sandeep.

    >
    How can we convert a file into PDF format in java?My application does the
    file upload, and I need the files to be converted into PDF format.
    The uploaded file can be of any type. ...>1) Write a class that will intelligently render a file of any type..
    2) ... (well, do '1' first, then after getting your Nobel prize for AI, come back and we'll talk)
    >
    Please give me some help.>Please review your requirement.
    BTW
    - PDF sucks. It is designed for printing, and I (for one) don't want to kill more trees, and have no printer.
    - This subject (convert file to PDF) has been discussed on the forums a bazillion times. Did you search the forums before asking your two (very closely related) questions?

  • Converting files into PDF/A format

    Hello,
    My main questions are:
    1) How can I convert a normal document (say, word document) into PDF/A format using Adobe Acrobat 8.0 standard (that's what we use in the office)?
    2) When we convert a file into PDF using Adobe Acrobat, does it save the file automatically in PDF/A format or is it normal PDF?
    3) How can I tell if a file is in PDF/A format?  Will it have a different extension than PDF?
    4) What disadvantages are there related to PDF/A format (if any)?

    Thanks pogopossum,
    I'm using now Goodreader. This has also the advantage of a good interlinking to other available documents.
    This is also not functioning with ibooks. Goodreader has some drawbacks compared to ibooks.
    You cannot recognize the books easily since no frontpages are present and you need to scroll more to find the correct document. A annoying thing is that once you enlarge the index and jump to a linked page that page will show up in the enlarged fashion. So you always need to resize the new page. This problem is not present in ibooks. An enormous good feature of Goodreader is the easy and many ways to import files.

  • How to batch convert Word files to pdf

    How do I batch convert Word files to pdf using Automator

    Here is a drag/drop AppleScript solution that uses the command-line LibreOffice capability to convert MS Word (.doc, .docx) files into PDF. Drag/Drop a single file, or a folder of Word documents, and it will write the respective PDF back to the original file location. When it is done, an OS X Notification will slide out onto the Desktop and provide the count of processed files.
    Save this AppleScript as a Desktop application that remains open after running. If you ignore the latter, the notification will not show when it is done. Tested on Mavericks 10.9.5.
    property name_extension : {"doc", "docx"}
    global fileCnt
    on open of finderObjects
        set fileCnt to 0
        repeat with i in (finderObjects)
        if folder of (info for i) is true then
            tell application "Finder" to set temp to (entire contents of i)
            repeat with j in (temp)
                process_files(j)
            end repeat
        else
              process_files(i)
        end if
        end repeat
        display notification "Processed Files: " & fileCnt with title "Word2PDF" subtitle "Processing Complete"
    end open
    on process_files(fname)
         set cmd to "/Applications/LibreOffice.app/Contents/MacOS/soffice "
         set cmdArgs to "--headless --convert-to pdf:writer_pdf_Export --outdir "
         tell application "Finder"
              set nameExt to name extension of fname
              set outDir to do shell script "dirname " & POSIX path of (fname as alias)
              if name extension of fname is in name_extension then
                   try
                        do shell script cmd & cmdArgs & outDir & space & POSIX path of (fname as alias)
                        set fileCnt to fileCnt + 1
                   on error errorMessage number errorNumber
                        display alert "Processing Error: " message "[ " & errorNumber & " ] " & errorMessage
                        error number -128
                   end try
              end if
         end tell
         return
    end process_files

  • Convert .WAR file into .Car file???

    Hello Everyone,
    Iam working on portlets and i have to deploy my portlet which is a .war file onto a "vignette" which is a portal,problem is vignette portal only accepts .Car file, Iam developing portals in Netbeans with glassfish server and open portal container 2.0. and it generates .War file of my application in the end,if anyone can please suggest me that how can i create or convert .War file into .Car file it will be a great relief for me.
    Thanks.
    Edited by: anie on Sep 20, 2008 10:53 AM

    mv i_am_stupi.war i_am_stupid.carOr just RTFM if you want to have a file that the system actually understands.

Maybe you are looking for

  • Does anyone know the pricing structure for Digital Marketing Suite?

    Does anyone know the pricing structure for Digital Marketing Suite? I asked for info but no one ever got back to me. I don't want to waste anyones time if it's too expensive so I'd like to know up front what the fees/package rates are. Thanks. Peter

  • Table leadSelection in Netweaver CE 7.1

    Hi experts, I have created a table with values in web dynpro. Now i want to display another item table on the same view when click on any row of the source table(NetWeaver 7.1). I used the onleadSelection action,but it is now only changable by clicki

  • Cant open Hyperlinks on my computer, how do I fix?

    Cant open Hyperlinks on my computer, how do I fix? OS X version 10.9.5. Terryfrombinghamton

  • ICC profiles - deleting

    I've got CS5 and I'm still learning the ropes.  I've advanced to creating my own ICC print profiles, which I'm using.  CS5 has a long list of these in the print dialogue.  I have occasionally updated the profiles that I have created ( which now appea

  • Question Re: Disk Space Utilization after Updates

    After updating to 10.5.3 this weekend I began to wonder about something. The download was a bit over 500 MB... during the actual install a prompt appears stating this would occupy approximately 1.6 GB ( not MB ) of disk space. Do updates actually tak