Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inserting Pictures


Using a Macro I need to insert various jpg pictures into an Excel
sheet.

These pictures are various sizes and need to be resized to the same
size.

Using VBA Is is possible to size a picture to a specific size? or to
get its current size and then calculate the % scaling required.


thanks in advance


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=531391

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Inserting Pictures

Try:

Sub InsertPicts()
Dim P As Picture
Dim FNm As Variant
Dim R As Single
Dim c As Range

Set c = Cells(3, 3)
With Application
FNm = .GetOpenFilename("Picture files(*.jpg), *.jpg")
If VarType(FNm) = vbBoolean Then Exit Sub
.ScreenUpdating = False
Set P = ActiveSheet.Pictures.Insert(FNm)
R = P.Width / P.Height
P.Top = c.Top
P.Left = c.Left
P.Height = 350
P.Width = R * P.Height 'correct proportionality after resizing
.ScreenUpdating = True
End With
End Sub

Pictures are now "Hidden Members" and we're supposed to use the shape
object's AddPicture method. The problem with AddPicture is that the height
and width properties are required arguments. So how does one know the
appropriate proportionality since picture files come in different shapes and
sizes ? I know I'm missing something here and am quite interested if someone
has the answer.

Regards,
Greg

"mudraker" wrote:


Using a Macro I need to insert various jpg pictures into an Excel
sheet.

These pictures are various sizes and need to be resized to the same
size.

Using VBA Is is possible to size a picture to a specific size? or to
get its current size and then calculate the % scaling required.


thanks in advance


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=531391


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default Inserting Pictures

Why not just do it with a photo editor in batch mode beforehand, you can do that with
IrfanView (irfanview.com) and many other free applications.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"mudraker" wrote in message
...

Using a Macro I need to insert various jpg pictures into an Excel
sheet.

These pictures are various sizes and need to be resized to the same
size.

Using VBA Is is possible to size a picture to a specific size? or to
get its current size and then calculate the % scaling required.


thanks in advance


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=531391



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Inserting Pictures

This a code written in VB.net.
In searches for all BMP files in the folder, resize it and save it to
JPEG.

Hope this will help.


Sub Main()
Dim objFile As FileInfo
Dim objFolder As New DirectoryInfo("C:\Photo\BMP")
Dim objFolderFI As FileInfo() = objFolder.GetFiles("*.bmp")
Dim jpgFileName As String

For Each objFile In objFolderFI
Dim objBMP As New Bitmap("C:\Photo\BMP\" & objFile.Name)
objBMP = New Bitmap(objBMP, New Size(150, 150))
jpgFileName = Left(objFile.Name, Len(objFile.Name) - 3) &
"jpg"
Console.WriteLine("Converting C:\Photo\BMP\" &
objFile.Name)
objBMP.Save("C:\Photo\JPG\" & jpgFileName,
ImageFormat.Jpeg)
Next
End Sub

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
Inserting Pictures cjohnson Excel Discussion (Misc queries) 2 April 2nd 08 07:00 PM
Inserting Pictures DamienO Excel Discussion (Misc queries) 2 October 31st 07 12:40 PM
Inserting Pictures Matthew[_2_] Excel Discussion (Misc queries) 3 July 14th 07 10:23 AM
Inserting pictures into worksheets Jose C Excel Discussion (Misc queries) 0 December 7th 06 04:06 AM
inserting pictures Denny[_2_] Excel Programming 5 November 16th 04 01:49 AM


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

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

About Us

"It's about Microsoft Excel"