Convert active excel wksht to pdf file [Solved/Closed]

- Mar 11, 2010 at 06:03 PM - Latest reply:  onedog1
- Mar 15, 2010 at 09:15 AM
Hello,
I'm trying to figure out how to create a macro to save an range selected in an active worksheet and save to a pdf file by clicking an inserted button.
See more 

14 replies

Posts
4481
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
- Mar 12, 2010 at 04:38 AM
0
Thank you
If you record your action, it will give you a macro template. Then you can modify it to suit your needs
I'm not very saavy in macros, so i've been able to get to the point yoiu suggested, I want to enhance now by prompting the user to save to file by clicking an inserted button.
Posts
4481
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
> onedog - Mar 12, 2010 at 08:57 AM
Could you explain what you mean prompt the user to save. Under what conditions the used is asked to save the file and why ask the user, if it can be saved on its own via macro or when user try to close the file excel will prompt. A little more background might help
onedog >
Posts
4481
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
- Mar 12, 2010 at 09:52 AM
Below is the vb script for where I'm at right now. All this does right now is open up the pdf file of the range wanted saved. before opening, I want to prompt the user to enter a filename. Thanks.

Sub SaveSO()
'
' SaveSO Macro
'

'
Range("B2:I50").Select
Range("I2").Activate
ChDir "C:\"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Desktop\book1.pdf", Quality _
:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub
Posts
4481
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
- Mar 12, 2010 at 10:14 AM
0
Thank you
I guess you are saying that you want user to enter a name for pdf file that you would use then in the code.

    Dim fileName As String
    
    fileName = ""
    Do While (fileName = "")
    
        fileName = InputBox("Save file as..", "Enter File name", "book1")
        
        fileName = Trim(fileName)
    Loop
    
    ActiveSheet.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            fileName:="C:\Desktop\" & fileName & ".pdf", _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=True


onedog >
Posts
4481
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
- Mar 12, 2010 at 02:49 PM
I just uploaded my file.
Posts
4481
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
> onedog - Mar 12, 2010 at 02:58 PM
You forgot to post the link here
onedog >
Posts
4481
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
- Mar 12, 2010 at 04:47 PM
The site showed me it was uploaded. see the following link
http://www.speedyshare.com/files/21396235/Copy_of_Longo_Dryer_Quote.xls
Posts
4481
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
> onedog - Mar 12, 2010 at 05:05 PM
You have code incorrect

See my message above
http://ccm.net/forum/affich-283846-convert-active-excel-wksht-to-pdf-file?#9


1. Remove all lines starting from

Sub SaveSO()

till the last line [ OpenAfterPublish:=True ( that you pasted from my earlier message) ]

2. Paste the code that is in

http://ccm.net/forum/affich-283846-convert-active-excel-wksht-to-pdf-file?#9

3. Make sure you have a sub folder or directory c:\desktop. If you do not have it, create one
onedog1 >
Posts
4481
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
- Mar 15, 2010 at 09:15 AM
Thank you. Thank you.