VBA - Export to JPG

j4ymf

Well-known Member
Joined
Apr 28, 2003
Messages
741
Office Version
  1. 365
Platform
  1. Windows
Hello

Im using this code and it converts my sheet to a PDF, can I change is so it exports it to a JPG

many thanks

Sub PrintSelectionToPDF()

' Creates the PDF from a selected range
Dim invoiceRng As Range
Dim strfile As String
Set invoiceRng = Range("A1:N44")
strfile = "" & " " & ".PDF"
strfile = ThisWorkbook.Path & strfile

invoiceRng.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strfile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=True, _
OpenAfterPublish:=True
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
thank you Joe4

objChart.Export ("D:StuffBusinessTempExample.Jpeg")

what would i use to save it in the current folder?
 
Upvote 0
I think you should be able to use your current "strfile" variable, assuming that is calculating correctly, i.e.
VBA Code:
objChart.Export (strfile)

But just be sure to change the file extension in that variable calculation from "PDF" to "JPG" or JPEG".
 
Upvote 0

Forum statistics

Threads
1,215,751
Messages
6,126,668
Members
449,326
Latest member
asp123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top