Reputation: 127
Hej, I am new in coding. I am trying my best but I am stuck. I have searched internet and stackoverflow but haven't find answer. I am writing code in Catia V5 VBA and I want to export excel to pdf. Excel has some pictures in color and I want that pdf is also in color. But I always end up with pdf in Black & white. This is my basic code:
Sub CATMain()
Set xlApp = CreateObject("Excel.Application")
Set mydoc = xlApp.Workbooks.Open("D:\Excel_1.xls")
Set mySheet = mydoc.Sheets.Item(1)
mySheet.ExportAsFixedFormat Type:=xlTypePDF, _
fileName:="D:\Excel_1.pdf", _
Quality:=xlQualityStandard, _
End Sub
I have looked for other parameters of "ExportAsFixedFormat" method, but there isn't any about color.
In despair I have also tried:
xlApp.ActiveWorkbook.SaveAs "D:\Excel_1.pdf"
But I get error saying: "Adobe Acribat could not open 'Excel_1.pdf' because it is either not a supported file type or because the file has been damaged"
Workbook.SaveAs method has "FileFormat" parameter but there isn't pdf in list of suportet file formats.
do you know what method should I use to get colored pdf?
thanks in advance
Upvotes: 3
Views: 1072
Reputation: 127
If someone have same problem as I did, just add this code before exporting to pdf:
mySheet.PageSetup.BlackAndWhite = False
this will set sheet to print in color.
so, code will look like this:
Sub CATMain()
Set xlApp = CreateObject("Excel.Application")
Set mydoc = xlApp.Workbooks.Open("D:\Excel_1.xls")
Set mySheet = mydoc.Sheets.Item(1)
mySheet.PageSetup.BlackAndWhite = False
mySheet.ExportAsFixedFormat Type:=xlTypePDF, _
fileName:="D:\Excel_1.pdf", _
Quality:=xlQualityStandard
End Sub
Upvotes: 2