Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
save a worksheet as template in excel 2007 | Excel Discussion (Misc queries) | |||
Save as file format excel worksheet 4.0 in Microsoft excel 2007 | Excel Discussion (Misc queries) | |||
How can I save a macro to an excel 2007 woorkbook | Excel Programming | |||
save single excel worksheet out of workbook in excel 2007 | Excel Discussion (Misc queries) | |||
How do I set up a macro to save an Excel worksheet as a .prn file? | Excel Programming |