Save as pdf with special name

M

Mia

Hi,

I'm trying to save a sheet with a namn from the sheet as a pdf.
Do anyone know what I should change in my code below to make it work?

Sub Saveas()

' Saveas Makro
'
'

Dim Namn As Integer


Sheets("Blad2").Select

Namn = Range("A1").Value


ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"M:\mc\Fevis\Namn.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False,
OpenAfterPublish:= _
False
Sheets("Blad1").Select

End Sub

BR
Mia
 
R

Ron de Bruin

Use this

You can remove the date/time stamp if you want

Sub RDB_PDF_ActiveSheet()
Dim FilenameStr As String

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

FilenameStr = Application.DefaultFilePath & "\" & _
ActiveSheet.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss") & ".pdf"

ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=FilenameStr, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "You can find the PDF file here : " & FilenameStr

Else
MsgBox "PDF add-in Not Installed"
End If
End Sub
 
M

Mia

Hi Ron,

It did not solve my problem completely. I want the pdf to always be saved at
the sam place.

M:\mc\Fevis\

And I also want the name to be from one cell in the active sheet. Is it
possible?

BR
Mia



"Ron de Bruin" skrev:
 
R

Ron de Bruin

Use this then

Sub RDB_PDF_ActiveSheet_2()
Dim FilenameStr As String

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

FilenameStr = "M:\mc\Fevis\" & _
ActiveSheet.Range("A1").Value & " " & Format(Now, "dd-mmm-yy h-mm-ss") & ".pdf"

ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=FilenameStr, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "You can find the PDF file here : " & FilenameStr

Else
MsgBox "PDF add-in Not Installed"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top