2016-11-16 41 views
1

PDFとして保存するシートを生成するマクロを実行しました。以下の方法を実行すると、私の文書が保存されていないことを知らせるエラーが表示されます(Run=time error '-2147024773 (8007007b)': Document not saved.ExportAsFixedFormatを使用してファイルを保存するときのエラー

私はそれに与えようとしているファイル名であると信じています。 。情報

すべての変数は、公的

Public Sub toPDF() 

    PDFName = "Pinger Report_" & Format(Now, "dd/mm/yyyy hh:mm:ss") 
    sumPDFSheet.Cells(5, 4).Value = Format(Now, "dd/mm/yyyy hh:mm:ss") 

    finalPDFName = PDFPath & PDFName 

    'create borders around failed devices range on pdfsheet 
     With sumPDFSheet.Range(sumPDFSheet.Cells(24, 3), sumPDFSheet.Cells(k - 1, 5)).Borders 
    .LineStyle = xlContinuous 
    End With 

    'creates heading rows for each page in the pdf and centers correctly 
    sumPDFSheet.PageSetup.PrintTitleRows = sumPDFSheet.Rows(1).Address 
    sumPDFSheet.PageSetup.CenterVertically = False 
    sumPDFSheet.PageSetup.CenterHorizontally = True 

    'method call to format columns 
    allColumns 

    'save as pdf to correct folder with correct name 
    With sumPDFSheet 
     .ExportAsFixedFormat Type:=xlTypePDF, Filename:=finalPDFName, openafterpublish:=False 'ERRRORRRRRRRRRERRRR 
    End With 

End Sub 
+2

変数に値「finalPDFNameが」正しいファイルの拡張子です何 –

+1

感謝指摘するために。あなたはファイルの拡張子で正しいです。 – Rivers31334

答えて

1

回答宣言されます。??正しいファイル拡張子を提供することを

関連する問題