Solved

Send/Print an Excel 2013 range to a PDF,  jpg, or other picture.   The range object is a calendar (1 month)

Posted on 2014-10-27
7
152 Views
Last Modified: 2014-10-29
I've been looking for a solution on this.   There are lots of solutions,  but there seem to be lots of caveats.

I need to send/print  a picture of the excel 2013 range to a file for easy viewing (no editing)  by other people.   It is only one page long.  I would prefer to send it as a PDF file, but I can't imagine why a jpg, png or other pic file wouldn't do the same thing.   I am using Gmail as my email provider.

Then that file would be added as an attachment to an email (manually for now).
0
Comment
Question by:peispud
7 Comments
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40407514
You can paste an image of any copied range of an Excel worksheet.

1) Select the range and then copy ([Ctrl]+[C])
2) Open a new email (assuming MS Outlook here)
3) Select the drop arrow below the "Paste" icon in the Clipboard section of the Message ribbon in your email form.
4) Select PasteSpecial.  You'll see a new dialog box.
5) Select "Picture (Enahnced Metafile)" and click the OK button.
paste special
This will display a scaled image of your selected range, including any charts.

Regards,
-Glenn
0
 

Author Comment

by:peispud
ID: 40407525
I appreciate your reply, but I am using Gmail.

Furthermore,  I am looking for a more automated solution.  This range represents one month of work scheduling. Although I could do this easily, others might find the procedure to be a bit too much.
0
 
LVL 25

Accepted Solution

by:
ProfessorJimJam earned 500 total points
ID: 40407542
HERE YOU GO   converts to pdf and then saves it in default folder of your application.


Sub SheetToPDF()
  Dim PdfFile As String, char As Variant, i As Long
  

  If Val(Application.Version) < 12 Then
    MsgBox "Export to PDF requires Excel 2007+", vbExclamation, "SheetToPDF"
    Exit Sub
  End If
  

  PdfFile = ActiveWorkbook.Name
  i = InStrRev(PdfFile, ".xl", , vbTextCompare)
  If i > 1 Then PdfFile = Left(PdfFile, i - 1)
  PdfFile = ActiveWorkbook.Path & "\" & PdfFile & "_" & ActiveSheet.Name
  For Each char In Split("? "" / \ < > * | :")
    PdfFile = Replace(PdfFile, char, "_")
  Next
  PdfFile = Left(PdfFile, 251) & ".pdf"
 
  With ActiveSheet
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
  End With
 

  MsgBox "PDF file:" & vbLf & PdfFile, vbInformation, "SheetToPdf"
 
End Sub

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:peispud
ID: 40407568
Another great answer and I will accept if gratefully, but I do have a question though about this code.

I had to comment out the following code in order for the file to be created in the same directory  as the Excel workbook.
I might add that I am using Windows 8.1.
My question.  What is the normal purpose for the code below?

 For Each char In Split("? "" / \ < > * | :")
    PdfFile = Replace(PdfFile, char, "_")
  Next

Open in new window

0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40407874
the line above was a code to replace any wrong character in case if used.   if you do not like it and it is confusing for you, then use the version below.


it will save it to the same folder and also do not include that addtional lines.

Sub SheetToPDF()
  Dim IsCreated As Boolean
  Dim i As Long
  Dim PdfFile As String, Title As String
  Dim OutlApp As Object
 
  PdfFile = ActiveWorkbook.FullName
  i = InStrRev(PdfFile, ".")
  If i > 1 Then PdfFile = Left(PdfFile, i - 1)
  PdfFile = PdfFile & "_" & ActiveSheet.Name & ".pdf"
 
  With ActiveSheet
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
  End With
  
  MsgBox "EXPORTED IN THE SAME FOLDER"
End Sub

Open in new window

0
 
LVL 7

Expert Comment

by:Katie Pierce
ID: 40409660
This might be a bit organic, but I downloaded a Google Chrome Extension called Lightshot. I use it everyday to screen shot Excel data and email it to interested parties.  I simply paste the screen shot into my email, but you could also paste it into a Word doc and PDF that if you needed to.
0
 

Author Closing Comment

by:peispud
ID: 40410604
Thank you all!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now