PC Review


Reply
Thread Tools Rate Thread

How to auto size jpeg files into excel when import/insert pictures

 
 
Ken C
Guest
Posts: n/a
 
      23rd Sep 2009
Is there an add-in that will auto size a picture within a specified area
without having to resize it all the time. I'm trying to design my own
trading journal and need to import screen shots saved as jpeg file into a
specified area. Any help would be greatly appreciated.
 
Reply With Quote
 
 
 
 
Bernie Deitrick
Guest
Posts: n/a
 
      23rd Sep 2009
You need to read, for example, the width of both the range where you are pasting, and the width of
the jpg:

With ActiveSheet
'Select the cell where the picture is placed
Range("rngForJPG").Cells(1,1).Select
'Insert the picture
.Pictures.Insert(myImageFileName).Select
'scale the picture to the width of the column
myScale = Range("rngForJPG").Cells(1,1).EntireColumn.Width / Selection.ShapeRange.Width
Selection.ShapeRange.ScaleWidth myScale, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight myScale, msoFalse, msoScaleFromTopLeft
'Change the row height to the picture height
Range("rngForJPG").Cells(1,1).EntireRow.RowHeight = Selection.ShapeRange.Height
End With

HTH,
Bernie
MS Excel MVP


"Ken C" <(E-Mail Removed)> wrote in message
news:BE459260-A1BD-4837-8CE2-(E-Mail Removed)...
> Is there an add-in that will auto size a picture within a specified area
> without having to resize it all the time. I'm trying to design my own
> trading journal and need to import screen shots saved as jpeg file into a
> specified area. Any help would be greatly appreciated.



 
Reply With Quote
 
Ken C
Guest
Posts: n/a
 
      24th Sep 2009
Bernie,
Does any one have an addin already designed that you can just drag from
the top left cell to the bottom right cell and like format it so that the
pics will autosize within that area? What you posted is that a VBA program
that has to be added for each area per sheet or is it an addin? I'm not very
adept on programming yet but have bought some books that walk you step by
step and also am using some online sites that have training. Thanks for the
input so far, I couldn't get an answer from three other sites about this
question.


"Bernie Deitrick" wrote:

> You need to read, for example, the width of both the range where you are pasting, and the width of
> the jpg:
>
> With ActiveSheet
> 'Select the cell where the picture is placed
> Range("rngForJPG").Cells(1,1).Select
> 'Insert the picture
> .Pictures.Insert(myImageFileName).Select
> 'scale the picture to the width of the column
> myScale = Range("rngForJPG").Cells(1,1).EntireColumn.Width / Selection.ShapeRange.Width
> Selection.ShapeRange.ScaleWidth myScale, msoFalse, msoScaleFromTopLeft
> Selection.ShapeRange.ScaleHeight myScale, msoFalse, msoScaleFromTopLeft
> 'Change the row height to the picture height
> Range("rngForJPG").Cells(1,1).EntireRow.RowHeight = Selection.ShapeRange.Height
> End With
>
> HTH,
> Bernie
> MS Excel MVP
>
>
> "Ken C" <(E-Mail Removed)> wrote in message
> news:BE459260-A1BD-4837-8CE2-(E-Mail Removed)...
> > Is there an add-in that will auto size a picture within a specified area
> > without having to resize it all the time. I'm trying to design my own
> > trading journal and need to import screen shots saved as jpeg file into a
> > specified area. Any help would be greatly appreciated.

>
>
>

 
Reply With Quote
 
Bernie Deitrick
Guest
Posts: n/a
 
      25th Sep 2009
Ken,

Select the cells (either manually or in code) where you want the picture to go, and then run this
macro.

Sub InsertAndResizePicture()

Dim myR As Range
Set myR = Selection
'Insert the picture
ActiveSheet.Pictures.Insert( _
Application.GetOpenFilename( _
"JPG picture files (*.jpg),*.jpg", , "Select the picture")).Select
'scale the picture to the width of the column
myScale = Application.Min(myR.Width / Selection.ShapeRange.Width, _
myR.Height / Selection.ShapeRange.Height)
Selection.ShapeRange.ScaleWidth myScale, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight myScale, msoFalse, msoScaleFromTopLeft
myR.select

End Sub


You of course can modify it to choose the range and filenames in code...


Sub InsertAndResizePicture2()

Dim myR As Range
Set myR = Range("Range_Name")
'Insert the picture
ActiveSheet.Pictures.Insert( "C:\PictureFiles\Picture1.jpg").Select
'scale the picture to the width of the column
myScale = Application.Min(myR.Width / Selection.ShapeRange.Width, _
myR.Height / Selection.ShapeRange.Height)
Selection.ShapeRange.ScaleWidth myScale, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight myScale, msoFalse, msoScaleFromTopLeft
myR.Select
End Sub

HTH,
Bernie
MS Excel MVP


"Ken C" <(E-Mail Removed)> wrote in message
news:E003D8FE-5FAE-4AB4-B931-(E-Mail Removed)...
> Bernie,
> Does any one have an addin already designed that you can just drag from
> the top left cell to the bottom right cell and like format it so that the
> pics will autosize within that area? What you posted is that a VBA program
> that has to be added for each area per sheet or is it an addin? I'm not very
> adept on programming yet but have bought some books that walk you step by
> step and also am using some online sites that have training. Thanks for the
> input so far, I couldn't get an answer from three other sites about this
> question.
>
>
> "Bernie Deitrick" wrote:
>
>> You need to read, for example, the width of both the range where you are pasting, and the width
>> of
>> the jpg:
>>
>> With ActiveSheet
>> 'Select the cell where the picture is placed
>> Range("rngForJPG").Cells(1,1).Select
>> 'Insert the picture
>> .Pictures.Insert(myImageFileName).Select
>> 'scale the picture to the width of the column
>> myScale = Range("rngForJPG").Cells(1,1).EntireColumn.Width / Selection.ShapeRange.Width
>> Selection.ShapeRange.ScaleWidth myScale, msoFalse, msoScaleFromTopLeft
>> Selection.ShapeRange.ScaleHeight myScale, msoFalse, msoScaleFromTopLeft
>> 'Change the row height to the picture height
>> Range("rngForJPG").Cells(1,1).EntireRow.RowHeight = Selection.ShapeRange.Height
>> End With
>>
>> HTH,
>> Bernie
>> MS Excel MVP
>>
>>
>> "Ken C" <(E-Mail Removed)> wrote in message
>> news:BE459260-A1BD-4837-8CE2-(E-Mail Removed)...
>> > Is there an add-in that will auto size a picture within a specified area
>> > without having to resize it all the time. I'm trying to design my own
>> > trading journal and need to import screen shots saved as jpeg file into a
>> > specified area. Any help would be greatly appreciated.

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista won't display JPEG files as pictures pbl Windows Vista General Discussion 2 18th Nov 2008 01:21 PM
Field size reduction on import of Excel, txt, etc files =?Utf-8?B?UGV0ZXI=?= Microsoft Access External Data 2 1st May 2007 09:23 PM
i want to import all pictures into excel at the same size without. =?Utf-8?B?TGF1cmEgVGF5bG9y?= Microsoft Excel Setup 0 21st Dec 2004 11:07 AM
How to insert pictures from file with an auto size scale in ppt 20 =?Utf-8?B?dGVyYTEyMw==?= Microsoft Powerpoint 1 19th Nov 2004 03:33 PM
FP 2K Adding JPEG scanned pictures (size) Tut Microsoft Frontpage 3 28th Apr 2004 08:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:22 PM.