Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default save excel 2007 worksheet as pdf in macro

Hi,

I have recorded a macro in excel 2007 (with the Acrobat tab) to save an
excel sheet as a pdf. I can get the macro to make the pdf but it will not
save it. This is the code i have recorded:

Sub Macro1()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"R:\Actuarial Data\Form Filing Project\formfilingschvol2..pdf",
Quality:= _
xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub

I changed it to this.

Sub pdf()
' creates a pdf of an excel worksheet
Dim stateint As String, shname As String, lob As String
stateint = Range("ca1").Value
shname = Range("ca4").Value
lob = Range("ca2").Value
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"R:\Actuarial Data\" & lob & "\Filings\2008\" & stateint & "\" &
shname & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End Sub

When I run either one I get the error message: Run-time error '1004'.
Document not saved. The document may be open, or an error may have been
encountered when saving. If anyone has any suggestions as to how I can fix
this it would be appreciated. Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mia Mia is offline
external usenet poster
 
Posts: 101
Default save excel 2007 worksheet as pdf in macro

Hi,

I think I have done a simular programming, try something like this.
You need pdf-add in.


Sub saveaspdft()
'
' Save as pdf Makro
'

Dim FilenameStr As String

If Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" _
& Format(Val(Application.Version), "00") & "\EXP_PDF.DLL") < "" Then

FilenameStr = "C:\Mina dokument\" & _
ActiveSheet.Range("F23").Value & " " & Format(Now, "yyyy-mm-dd") &
".pdf"

ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=FilenameStr, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True,_

MsgBox " xxxx are now saved at " & FilenameStr

Else
MsgBox "PDF add-in are not installed"
End If
End Sub



As you can se I´m getting the filename from cell F3

God luck!

//
Mia









"Jania" skrev:

Hi,

I have recorded a macro in excel 2007 (with the Acrobat tab) to save an
excel sheet as a pdf. I can get the macro to make the pdf but it will not
save it. This is the code i have recorded:

Sub Macro1()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"R:\Actuarial Data\Form Filing Project\formfilingschvol2..pdf",
Quality:= _
xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub

I changed it to this.

Sub pdf()
' creates a pdf of an excel worksheet
Dim stateint As String, shname As String, lob As String
stateint = Range("ca1").Value
shname = Range("ca4").Value
lob = Range("ca2").Value
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"R:\Actuarial Data\" & lob & "\Filings\2008\" & stateint & "\" &
shname & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End Sub

When I run either one I get the error message: Run-time error '1004'.
Document not saved. The document may be open, or an error may have been
encountered when saving. If anyone has any suggestions as to how I can fix
this it would be appreciated. Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default save excel 2007 worksheet as pdf in macro

Hi Jania

See
http://www.rondebruin.nl/pdf.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jania" wrote in message ...
Hi,

I have recorded a macro in excel 2007 (with the Acrobat tab) to save an
excel sheet as a pdf. I can get the macro to make the pdf but it will not
save it. This is the code i have recorded:

Sub Macro1()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"R:\Actuarial Data\Form Filing Project\formfilingschvol2..pdf",
Quality:= _
xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub

I changed it to this.

Sub pdf()
' creates a pdf of an excel worksheet
Dim stateint As String, shname As String, lob As String
stateint = Range("ca1").Value
shname = Range("ca4").Value
lob = Range("ca2").Value
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"R:\Actuarial Data\" & lob & "\Filings\2008\" & stateint & "\" &
shname & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End Sub

When I run either one I get the error message: Run-time error '1004'.
Document not saved. The document may be open, or an error may have been
encountered when saving. If anyone has any suggestions as to how I can fix
this it would be appreciated. Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
save a worksheet as template in excel 2007 DTP941 Excel Discussion (Misc queries) 3 October 21st 09 05:12 PM
Save as file format excel worksheet 4.0 in Microsoft excel 2007 Saria Excel Discussion (Misc queries) 1 July 14th 08 11:39 AM
How can I save a macro to an excel 2007 woorkbook help Excel Programming 1 December 6th 07 01:27 AM
save single excel worksheet out of workbook in excel 2007 rokbroscore Excel Discussion (Misc queries) 2 July 13th 07 09:43 PM
How do I set up a macro to save an Excel worksheet as a .prn file? cher Excel Programming 2 March 1st 06 03:50 PM


All times are GMT +1. The time now is 10:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"