+ Reply to Thread
Results 1 to 10 of 10

Excel To Pdf error

Hybrid View

mohan.r1980 Excel To Pdf error 02-28-2012, 05:24 AM
JapanDave Re: Excel To Pdf error 02-28-2012, 05:56 AM
royUK Re: Excel To Pdf error 02-28-2012, 06:10 AM
mohan.r1980 Re: Excel To Pdf error 02-28-2012, 07:07 AM
Domski Re: Excel To Pdf error 02-28-2012, 07:20 AM
mohan.r1980 Re: Excel To Pdf error 02-28-2012, 07:57 AM
mohan.r1980 Re: Excel To Pdf error 02-28-2012, 08:20 AM
Domski Re: Excel To Pdf error 02-28-2012, 09:21 AM
mohan.r1980 Re: Excel To Pdf error 02-29-2012, 01:11 AM
Domski Re: Excel To Pdf error 02-29-2012, 05:34 AM
  1. #1
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Smile Excel To Pdf error

    Hi Friends
    i am trying to save active worksheet as pdf

    But i am getting "Run time error 5 and Invalid procedure call or argument" error message

    i get this code on Google search.

    please suggest me where i am getting wrong

    Sub SaveToPDF()
        With ActiveSheet
            .ExportAsFixedFormat _
                    Type:=xlTypePDF, _
                    Filename:="C:\Test\Test.pdf", _
                    OpenAfterPublish:=False
        End With
    End Sub

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Excel To Pdf error

    Do you have the PDF addin? I believe you need it.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel To Pdf error

    You need the pdf addin for Excel 2007.

    It will not work at all in earlier versions
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Excel To Pdf error

    hi friends,
    i am using 64 bit pc and excel 2007 so what should i do for pdf add in?

  5. #5
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  6. #6
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Excel To Pdf error

    thanks Domski

    It runs fine
    but the problem is that i can not set the paper size.
    if i set the A4 size in worksheet and then run this code
    pdf make size "9.24 X 11.96" which is not a A4 size

    thanks in advance

  7. #7
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Excel To Pdf error

    Hi Domski

    i am making project on my Pc, My pc have Excel 2007
    when i run this excel to another pc where xl2003 then it show me error

    see below code

    Dim sh As Worksheet
       Set sh = Sheets("sheet1")
       
       sh.ExportAsFixedFormat xlTypePDF, "D:\Transfer\Test.pdf"
    In xl2003 it show error xlTypePDF "variable not define"

    i know SaveAsPDF.exe support only xl 2007.
    is there have any exe which support both xl 2003 & 2007.

  8. #8
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Excel To Pdf error

    The ability to create pdf files within MS Office was only introduced in Office 2007. You can't use that method in 2003.

    You need to use a pdf software like Adobe Acrobat Pro that can be controlled using VBA as an alternative.

    Dom

  9. #9
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Excel To Pdf error

    thanks Domski

    but what about setting of paper size A4 in my code
    will you help me to set the paper size in A4

    thanks in advance

  10. #10
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Excel To Pdf error

    As far as I know that should all be done in page setup.

    Dom

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1