Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

Excel VBA for Mac : Save worksheet as PDF

$
0
0

I am actually working on a simple macro to save the active sheet as a PDF file with a special name. The macro I have created is working but it is saving every sheets in several PDF and put the name of the sheet at the end of the file name.

If you could help me it would be great, i cannot see what is the problem...

Here is my macro :

Sub PrintPDF() 
    Dim wksSheet As Worksheet 
    Dim strFile As String 

    Set wksSheet = ActiveSheet 
    'strFile = Format(Now(), "yyyymm") _ 
                & ".pdf" 

    strFile = "blabla" _ 
                & "_" _ 
                & Format(Now(), "yyyymm") _ 
                & "_" _ 
                & "name2" _ 
                & "" _ 
                & Replace(Replace(wksSheet.Cells(1, 2).Value, "", ""), ".", "_") _ 
                & ".pdf" 

    strFile = ThisWorkbook.Path & ":"& strFile 

    wksSheet.SaveAs Filename:=strFile, FileFormat:=xlPDF 
End Sub 

Viewing all articles
Browse latest Browse all 88835

Trending Articles