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
155 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Getting error in connectionstring with Excel. 30 31
Real Time 2 21
Concatenate  strings with original parameters 21 41
Route Recommendation 18 31
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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…

785 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