VBA script that saves Excel range in pdf format

I tried to inject the range into my code, but I had no luck. I would like to have a script in vba to “save as” a specific sheet or a specific range in pdf. Any help would be greatly appreciated.

Here is what I worked with:

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "c:\Book1.pdf", Quality:= _ xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _ OpenAfterPublish:=True 

Thanks,

+7
source share
2 answers

you have code, just use range instead of activesheet

eg. Sheets("Sheet1").Range("B2:H28").ExportAsFixedFormat ...

+16
source

I tried the following code but it does not work. In the range ("W2") I have the following ranges:

A1: G60, A61: G119, A12: G178, A179: G237, A238: G296, A297: G355, A356: G414, A415: G473, A474: G532, A533: G591

Does anyone have an idea?

Dim Imprimir like a string

imprimir = Application.Sheets ("Sheets2"). Range ("W2"). Value

Sheets ("Sheets1"). Range (imprimir) .ExportAsFixedFormat Type: = xlTypePDF, Quality: = xlQualityStandard, IncludeDocProperties: = True, IgnorePrintAreas: = False, OpenAfterPublish: = True

thanks

0
source

All Articles