ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   alternative to using the 'chart method' to exporting range as .jpg file (https://www.excelbanter.com/excel-programming/428875-alternative-using-chart-method-exporting-range-jpg-file.html)

ARbitOUR[_11_]

alternative to using the 'chart method' to exporting range as .jpg file
 

Hi all...

I have posted a similar question as this one using a different heading
(maybe I'm hoping on catching a diff. audience...lol)

Anyways, I need to export a set range as a .jpg image file. However I
have noticed that resorting to exporting it via a chart results in
reduced image quality when compared to manually selecting the range and
copying into MS Paint and then saving it as a JPG.

So, does anyone out there maybe have some VBA code I can use that will
use MS Paint to achieve this?

Pls?
...

Pretty Pls?

???

Thx in advance...


--
ARbitOUR
------------------------------------------------------------------------
ARbitOUR's Profile: http://www.thecodecage.com/forumz/member.php?userid=254
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=99833


Héctor Miguel

alternative to using the 'chart method' to exporting range as .jpg file
 
hi, !

does this help: - http://tinyurl.com/of4try

hth,
hector.

__ OP __
I have posted a similar question as this one using a different heading
(maybe I'm hoping on catching a diff. audience...lol)

Anyways, I need to export a set range as a .jpg image file.
However I have noticed that resorting to exporting it via a chart results in reduced image quality
when compared to manually selecting the range and copying into MS Paint and then saving it as a JPG.

So, does anyone out there maybe have some VBA code I can use that will use MS Paint to achieve this?




Héctor Miguel

alternative to using the 'chart method' to exporting range as .jpg file
 
hi (again), !

other alternates:

http://www.mvps.org/dmcritchie/excel/xl2gif.htm
http://www.andypope.info/vba/gex.htm
http://www.pdfforge.org/products/pdfcreator
http://sourceforge.net/projects/pdfcreator

hth,
hector.



Jon Peltier

alternative to using the 'chart method' to exporting range as .jpg file
 
Hector -

Please post the whole link, so we can decide whether to click on it.

- Jon
-------
Jon Peltier, Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/

Advanced Excel Conference - June 17-18 2009 - Charting and Programming
http://peltiertech.com/Training/2009...00906ACNJ.html
_______


"Héctor Miguel" wrote in message
...
hi, !

does this help: - http://tinyurl.com/of4try

hth,
hector.

__ OP __
I have posted a similar question as this one using a different heading
(maybe I'm hoping on catching a diff. audience...lol)

Anyways, I need to export a set range as a .jpg image file.
However I have noticed that resorting to exporting it via a chart results
in reduced image quality
when compared to manually selecting the range and copying into MS Paint
and then saving it as a JPG.

So, does anyone out there maybe have some VBA code I can use that will
use MS Paint to achieve this?






Jon Peltier

alternative to using the 'chart method' to exporting range as .jpg file
 
Why do you need jpg? jpg is the worst format you can select for a
text/lineart type of image.

http://peltiertech.com/WordPress/why...-and-not-jpeg/

If you use png instead of jpg, is the image quality still poor?

- Jon
-------
Jon Peltier, Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/

Advanced Excel Conference - June 17-18 2009 - Charting and Programming
http://peltiertech.com/Training/2009...00906ACNJ.html
_______


"ARbitOUR" wrote in message
...

Hi all...

I have posted a similar question as this one using a different heading
(maybe I'm hoping on catching a diff. audience...lol)

Anyways, I need to export a set range as a .jpg image file. However I
have noticed that resorting to exporting it via a chart results in
reduced image quality when compared to manually selecting the range and
copying into MS Paint and then saving it as a JPG.

So, does anyone out there maybe have some VBA code I can use that will
use MS Paint to achieve this?

Pls?
..

Pretty Pls?

???

Thx in advance...


--
ARbitOUR
------------------------------------------------------------------------
ARbitOUR's Profile:
http://www.thecodecage.com/forumz/member.php?userid=254
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=99833




ARbitOUR[_12_]

alternative to using the 'chart method' to exporting range as .jpg file
 

Hi all,

Jon, To me it won't matter much weather the result is JPG or PNG.
However I have noticed an improvement in image quality when using PNG
instead of JPG (using a manual copy / paste method).

Let me explain the detail of what I intend on doing.

I am in the process of creating an extensive pricelist database and
quotation template. The quotation template already contains various
other macros.

In a nutshell, all that I require is a macro that takes the set range
of the quotation template and prepares an image file that is ready for
E-mailing. Different users will be utilizing different e-mail clients /
software, so I need to refrain from creating a 'ready-to-go email' in
something like Outlook, since obviously not everybody uses outlook...

I don't wish to use a macro that copies the set range to a chart and
then export it, as I have noticed a great reduction in image quality
when I tried doing this using the JPG format. I am willing to use other
formats, as long as it is a standard image format that can be opened by
the majority of image viewers. I wish to avoid using BMP's since the
result would be images (quotations) that would be unecesarily large in
size, thereby resulting in longer download / upload times.


The majority of code is complete, I just need to instruct MS Paint to
save the image to the desktop in JPG format, OR PNG (Since it does
provide a slight improvement on image quality, and a reduction in size)

I have added a control button to the main quotation template to which
the following macro is linked:





Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Public Function FileExists(FileName As String) As Boolean

Dim iTemp As Integer
On Error Resume Next

On Error Resume Next
iTemp = GetAttr(FileName)
Select Case Err.Number
Case Is = 0
FileExists = True
Case Else
FileExists = False
End Select
On Error GoTo 0

End Function

Sub EMail_Prep()

Dim MSPaint, i As Integer
Dim PriceList As Workbook
Dim QuoteSht As Worksheet
Dim MailPrepConfirm As String
Dim Answer As String
Dim Wait As Long
On Error Resume Next

MailPrepConfirm = "Proceed with E-Mail prep?"
Answer = MsgBox(MailPrepConfirm, vbQuestion + vbYesNo, "E-MAIL
PREP")

If Answer = vbYes Then
Application.WindowState = xlMinimized

' Open Price Lists, unprotect sheet: "Quote"
If FileExists(ThisWorkbook.path & "\HC Price Lists.xlsm")
Then

Application.WindowState = xlMaximized
MsgBox ("This quotation has not been saved yet. Please
use the 'Save Quotation' button to first save the quotation before
running 'E-Mail Prep'." & _
" Click OK to exit."), vbExclamation, "E-MAIL PREP"
Application.WindowState = xlMinimized
GoTo EarlyExit
Else

' Close Price List if open
If FileExists(ThisWorkbook.path & "\..\Quote
Template\HC Price Lists.xlsm") Then
For Each PriceList In Workbooks
If PriceList.Name = "HC Price Lists.xlsm" Then
PriceList.Activate
If ActiveWorkbook.ReadOnly = True Then
ActiveWorkbook.Close
SaveChanges:=False
Else
Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=True
Application.DisplayAlerts = True
End If
Else
End If
Next

' Open Price List and MSPaint
MSPaint = Shell("mspaint.exe", 1)

'Delay until MS Paint is open
Do Until Wait < 0
DoEvents
Wait = FindWindow("MSPaintApp", "untitled -
Paint")
Loop

Application.WindowState = xlMinimized
Set PriceList = Workbooks.Open(ThisWorkbook.path &
"\..\Quote Template\HC Price Lists.xlsm",
ignorereadonlyrecommended:=True)
Set QuoteSht = ThisWorkbook.Sheets("Quote")
QuoteSht.Activate
QuoteSht.Unprotect Password:=Workbooks("HC Price
Lists.xlsm").Worksheets("Belgotex").Range("W1")

' Copy range to MSPaint and protect QuoteSht
Range("A1:W67").CopyPicture
Appearance:=xlScreen, Format:=xlPicture
ActiveSheet.Protect Password:=Workbooks("HC
Price Lists.xlsm").Worksheets("Belgotex").Range("W1")
AppActivate MSPaint
SendKeys "^v", True

Else
MsgBox ("Unable to execute 'E-Mail Prep'. This
quotation has been moved from it's default location." & _
" To be able to run the 'E-Mail Prep' process, This
quotation first needs to be moved to it's default location." & _
" For quotations that have been saved previously,
the default location is the folder 'Quotes Issued'." & _
" For quotations that have not been saved
previously, the default location is the folder 'Quote Template'." & _
" If this problem persists, please contact DQS.
Click OK to exit."), vbCritical, "E-MAIL PREP"
GoTo EarlyExit
End If
End If

Application.WindowState = xlMaximized
Else
MsgBox "E-Mail prep cancelled. Click OK to exit.",
vbExclamation, "E-MAIL PREP"
GoTo EarlyExit
End If

EarlyExit:
Application.CutCopyMode = False
Set PriceList = Nothing
Set QuoteSht = Nothing

End Sub



Any help on the saving part???

Thx all

PS. Hector, thx for the help sofar, however, most of the links you
provided explains using PDF convertes or the 'Chart-method'.


--
ARbitOUR
------------------------------------------------------------------------
ARbitOUR's Profile: http://www.thecodecage.com/forumz/member.php?userid=254
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=99833


Héctor Miguel

alternative to using the 'chart method' to exporting range as .jpg file
 
hi, Sir !

here is the complete link:

http://groups.google.com.mx/group/mi....public.excel*

regards,
hector.

Jon Peltier wrote in message ...
Hector -

Please post the whole link, so we can decide whether to click on it.

- Jon
-------
Jon Peltier, Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/

Advanced Excel Conference - June 17-18 2009 - Charting and Programming
http://peltiertech.com/Training/2009...00906ACNJ.html
_______


"Héctor Miguel" wrote in message ...
hi, !

does this help: - http://tinyurl.com/of4try

hth,
hector.

__ OP __
I have posted a similar question as this one using a different heading
(maybe I'm hoping on catching a diff. audience...lol)

Anyways, I need to export a set range as a .jpg image file.
However I have noticed that resorting to exporting it via a chart results in reduced image quality
when compared to manually selecting the range and copying into MS Paint and then saving it as a JPG.

So, does anyone out there maybe have some VBA code I can use that will use MS Paint to achieve this?




ARbitOUR[_13_]

alternative to using the 'chart method' to exporting range as .jpg file
 

Hi All!

I've finally found the code I need to save the contents in MS Paint
(originally copied from Excel) in the required image format (.jpg =
lower quality than .png, but more compatible with various image
viewers). So here's the code to insert into the sub, after having
shelled MS Paint:




' Set Save As Parms
FileName = ThisWorkbook.Name

Application.Wait Now + TimeValue("00:00:01")
SendKeys ALT & "F", True ' File Menu
DoEvents
Application.Wait Now + TimeValue("00:00:01")
SendKeys "A", True ' Save As dialog
DoEvents
Application.Wait Now + TimeValue("00:00:01")
SendKeys Left(FileName, Len(FileName) - 1), True
DoEvents
SendKeys "{BACKSPACE 4}", True
DoEvents
SendKeys ".jpg", True ' Set image format
DoEvents
Application.Wait Now + TimeValue("00:00:02")
SendKeys "{TAB}", True ' Select 'save as
type' drop down menu
DoEvents
Application.Wait Now + TimeValue("00:00:01")
SendKeys "{DOWN 2}", True ' Select .jpg file
format
DoEvents
Application.Wait Now + TimeValue("00:00:01")
SendKeys "{ENTER}", True ' Activate
selection
DoEvents
Application.Wait Now + TimeValue("00:00:01")
SendKeys ALT & "S", True ' Save
DoEvents
Application.Wait Now + TimeValue("00:00:03")

'Close MS Paint
SendKeys ALT & "{F4}", True
DoEvents





I had to adapt the code for MS Paint for Windows XP to select the .jpg
format from the 'Save As Type' drop-down box. In MS Paint for Vista,
this part is not required since it automatically accepts the format as
specified by the extension.

Thanx to all of you for your valuable input!

ARbitOUR


--
ARbitOUR
------------------------------------------------------------------------
ARbitOUR's Profile: http://www.thecodecage.com/forumz/member.php?userid=254
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=99833


Jon Peltier

alternative to using the 'chart method' to exporting range as .jpg file
 
I guess I don't understand the problem with copying a range into an empty
chart, then exporting as PNG. The poor quality of a JPG produced this way is
irrelevant to the corresponding PNG. Any modern image viewer should read
PNGs with no trouble.

Also, any solution that relies on SendKeys will be prone to error.

- Jon
-------
Jon Peltier, Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/

Advanced Excel Conference - June 17-18 2009 - Charting and Programming
http://peltiertech.com/Training/2009...00906ACNJ.html
_______


"ARbitOUR" wrote in message
...

Hi All!

I've finally found the code I need to save the contents in MS Paint
(originally copied from Excel) in the required image format (.jpg =
lower quality than .png, but more compatible with various image
viewers). So here's the code to insert into the sub, after having
shelled MS Paint:




' Set Save As Parms
FileName = ThisWorkbook.Name

Application.Wait Now + TimeValue("00:00:01")
SendKeys ALT & "F", True ' File Menu
DoEvents
Application.Wait Now + TimeValue("00:00:01")
SendKeys "A", True ' Save As dialog
DoEvents
Application.Wait Now + TimeValue("00:00:01")
SendKeys Left(FileName, Len(FileName) - 1), True
DoEvents
SendKeys "{BACKSPACE 4}", True
DoEvents
SendKeys ".jpg", True ' Set image format
DoEvents
Application.Wait Now + TimeValue("00:00:02")
SendKeys "{TAB}", True ' Select 'save as
type' drop down menu
DoEvents
Application.Wait Now + TimeValue("00:00:01")
SendKeys "{DOWN 2}", True ' Select .jpg file
format
DoEvents
Application.Wait Now + TimeValue("00:00:01")
SendKeys "{ENTER}", True ' Activate
selection
DoEvents
Application.Wait Now + TimeValue("00:00:01")
SendKeys ALT & "S", True ' Save
DoEvents
Application.Wait Now + TimeValue("00:00:03")

'Close MS Paint
SendKeys ALT & "{F4}", True
DoEvents





I had to adapt the code for MS Paint for Windows XP to select the .jpg
format from the 'Save As Type' drop-down box. In MS Paint for Vista,
this part is not required since it automatically accepts the format as
specified by the extension.

Thanx to all of you for your valuable input!

ARbitOUR


--
ARbitOUR
------------------------------------------------------------------------
ARbitOUR's Profile:
http://www.thecodecage.com/forumz/member.php?userid=254
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=99833





All times are GMT +1. The time now is 03:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com