Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code to insert images in excel sheet

Hi all
I want a sample code that inserts images in an exce sheet
using VB, and also scales these images to a constant size.
Thanks for help
Regards
Riya
  #2   Report Post  
Posted to microsoft.public.excel.programming
raj raj is offline
external usenet poster
 
Posts: 32
Default VBA code to insert images in excel sheet

'MS Excel object variables
Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
Dim objWorkSheet As Excel.Worksheet

Set objExcel = GetObject
("", "excel.application") ' Start the excel COM
Set objWorkBook =
objExcel.Workbooks.Add ' Start a workbook.
objExcel.DisplayAlerts =
False ' Turn off the alerts
Do While objWorkBook.Worksheets.Count
1 ' keeps only one worksheet in the workbook
Set objWorkSheet = objWorkBook.Worksheets.Item
(objWorkBook.Worksheets.Count)
objWorkSheet.Delete
Loop
Set objWorkSheet =
objExcel.ActiveSheet ' Set objWorksheet to
the remaining worksheet.
objExcel.Visible = True

objWorkSheet.Pictures.Insert
("C:\Pic1.Jpg") ' Insert a picture

'scale picture
objWorkSheet.Pictures("Picture 1").Width = 200
objWorkSheet.Pictures("Picture 1").Height = 200
objWorkSheet.Pictures("Picture 1").Top = 200
objWorkSheet.Pictures("Picture 1").Left = 100
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code to insert images in excel sheet

'Hope this is what you want

'MS Excel object variables
Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
Dim objWorkSheet As Excel.Worksheet

Set objExcel = GetObject
("", "excel.application") ' Start the excel COM
Set objWorkBook =
objExcel.Workbooks.Add ' Start a workbook.
objExcel.DisplayAlerts =
False ' Turn off the alerts
Do While objWorkBook.Worksheets.Count
1 ' keeps only one worksheet in the workbook
Set objWorkSheet = objWorkBook.Worksheets.Item
(objWorkBook.Worksheets.Count)
objWorkSheet.Delete
Loop
Set objWorkSheet =
objExcel.ActiveSheet ' Set objWorksheet to
the remaining worksheet.
objExcel.Visible = True

objWorkSheet.Pictures.Insert
("C:\Pic1.Jpg") ' Insert a picture

'scale picture
objWorkSheet.Pictures("Picture 1").Width = 200
objWorkSheet.Pictures("Picture 1").Height = 200
objWorkSheet.Pictures("Picture 1").Top = 200
objWorkSheet.Pictures("Picture 1").Left = 100
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
Is there a way to insert images into unlocked cells martin Excel Discussion (Misc queries) 1 December 15th 08 10:51 PM
Insert Images Using Conditional Format (Many) Mike Garcia Excel Discussion (Misc queries) 4 October 4th 07 03:25 PM
insert images in a protected worksheet kub Excel Worksheet Functions 10 July 28th 07 11:31 AM
I want glitter images to insert rita New Users to Excel 1 February 27th 06 10:00 PM
How do I insert/update VBA code into a sheet? (using a CLS file?) Chip Pearson Excel Programming 0 September 14th 03 10:37 PM


All times are GMT +1. The time now is 08: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"