View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
[email protected] arthurjr07@gmail.com is offline
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