تبدیل شیت به pdf و ذخیره به نام دلخواه (آموزشی)

Collapse
X
 
  • زمان
  • نمایش
حذف همه
new posts
  • ali.b

    • 2014/01/12
    • 798

    تبدیل شیت به pdf و ذخیره به نام دلخواه (آموزشی)

    سلام دوستان
    با این کد میتونید شیت مورد نظر رو به PDF تبدیل کنین و جالب اینکه میتونین از سه تا سلول یا بیشتر به عنوان اسم فایلتون انتخاب کنید
    کد:
    [COLOR=#E56717][FONT=Consolas][B]Sub[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] SaveAsPDF()[/FONT][/COLOR]
    [COLOR=#008000][FONT=Consolas]'Saves active worksheet as pdf using concatenation
    [/FONT][/COLOR][COLOR=#008000][FONT=Consolas]'of A1,A2,A3
    [/FONT][/COLOR]
    [COLOR=#151B8D][FONT=Consolas][B]Dim[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] fName [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]As[/B][/FONT][/COLOR][COLOR=#F660AB][FONT=Consolas][B]String[/B][/FONT][/COLOR]
    [COLOR=#8D38C9][FONT=Consolas][B]With[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] ActiveSheet[/FONT][/COLOR]
    [COLOR=#141414][FONT=Consolas]    fName = .Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A1"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas]).Value & .Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A2"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas]).Value & .Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A3"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas]).Value[/FONT][/COLOR]
    [COLOR=#141414][FONT=Consolas]    .ExportAsFixedFormat [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]Type[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas]:=xlTypePDF, Filename:= _[/FONT][/COLOR]
    [COLOR=#800000][FONT=Consolas]"C:\My Documents\"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas] & fName, Quality:=xlQualityStandard, _[/FONT][/COLOR]
    [COLOR=#141414][FONT=Consolas]            IncludeDocProperties:=[/FONT][/COLOR][COLOR=#00C2FF][FONT=Consolas][B]True[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas], IgnorePrintAreas:=[/FONT][/COLOR][COLOR=#00C2FF][FONT=Consolas][B]False[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas], OpenAfterPublish:=[/FONT][/COLOR][COLOR=#00C2FF][FONT=Consolas][B]False[/B][/FONT][/COLOR]
    [COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]With[/B][/FONT][/COLOR]
    [COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#E56717][FONT=Consolas][B]Sub
    [/B][/FONT][/COLOR]
    [CENTER]
    [/CENTER]
  • ali.b

    • 2014/01/12
    • 798

    #2
    کد:
    [COLOR=#E56717][FONT=Consolas][B]Sub[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] SaveAsPDF()[/FONT][/COLOR]
    
    
    [COLOR=#151B8D][FONT=Consolas][B]Dim[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] fName [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]As[/B][/FONT][/COLOR][COLOR=#F660AB][FONT=Consolas][B]String[/B][/FONT][/COLOR]
    [COLOR=#8D38C9][FONT=Consolas][B]With[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas] Worksheets([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"My Sheet"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas])[/FONT][/COLOR]
    [COLOR=#141414][FONT=Consolas]    fName = .Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A1"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas]).Value & .Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A2"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas]).Value & .Range([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]"A3"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas]).Value[/FONT][/COLOR]
    [COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#8D38C9][FONT=Consolas][B]With[/B][/FONT][/COLOR]
    [COLOR=#141414][FONT=Consolas]ActiveSheet.ExportAsFixedFormat [/FONT][/COLOR][COLOR=#151B8D][FONT=Consolas][B]Type[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas]:=xlTypePDF, Filename:= _[/FONT][/COLOR]
    [COLOR=#800000][FONT=Consolas]"C:\My Documents\"[/FONT][/COLOR][COLOR=#141414][FONT=Consolas] & fName, Quality:=xlQualityStandard, _[/FONT][/COLOR]
    [COLOR=#141414][FONT=Consolas]            IncludeDocProperties:=[/FONT][/COLOR][COLOR=#00C2FF][FONT=Consolas][B]True[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas], IgnorePrintAreas:=[/FONT][/COLOR][COLOR=#00C2FF][FONT=Consolas][B]False[/B][/FONT][/COLOR][COLOR=#141414][FONT=Consolas], OpenAfterPublish:=[/FONT][/COLOR][COLOR=#00C2FF][FONT=Consolas][B]False[/B][/FONT][/COLOR]
    
    [COLOR=#8D38C9][FONT=Consolas][B]End[/B][/FONT][/COLOR][COLOR=#E56717][FONT=Consolas][B]Sub[/B][/FONT][/COLOR]
    این کد برای شیت مورد نظر هست
    Last edited by ~M*E*H*D*I~; 2014/06/25, 08:43.
    [CENTER]
    [/CENTER]

    کامنت

    • arash2152

      • 2014/01/13
      • 6
      • 42.00

      #3
      چگونه میشه دو شیت از سه شیت یک فایل اکسل را تیدیل به یک فایل PDF کرد؟
      ترجیحا اگه Print area متغیر و از مثلا یکی از سلول ها بخونه خیلی بهتره
      آیا میشه بصورت فوتر بهش شماره صفحه داد؟

      کامنت

      چند لحظه..