Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 17
Default How to auto size jpeg files into excel when import/insert pictures

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.
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 5,441
Default How to auto size jpeg files into excel when import/insert pictures

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" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 17
Default How to auto size jpeg files into excel when import/insert pict

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" wrote in message
...
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.




  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 5,441
Default How to auto size jpeg files into excel when import/insert pict

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" wrote in message
...
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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with auto insert of pictures Bradley Wolosz New Users to Excel 3 August 25th 08 12:28 PM
how do I import a csv files to execl and be extrad on clume auto saber55 New Users to Excel 0 February 16th 06 01:30 PM
insert a JPEG into EXCEL 2002 mckee Excel Discussion (Misc queries) 3 March 11th 05 05:03 PM
jpeg files in excel Andre Excel Discussion (Misc queries) 1 February 5th 05 08:12 AM
i want to import all pictures into excel at the same size without. Laura Taylor Setting up and Configuration of Excel 0 December 21st 04 11:07 AM


All times are GMT +1. The time now is 10:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"