View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
ARbitOUR[_13_] ARbitOUR[_13_] is offline
external usenet poster
 
Posts: 1
Default 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