help inserting image in Excel

madmakis

New member
Joined
Jun 7, 2006
Messages
1
Programming Experience
Beginner
i'm trying to insert an image on the top of the excel

the code im using is

VB.NET:
Sub ClearAndClose()
 
Excel.Application.Quit
End Sub
Sub PrintPriceListF()
'
' PrintPriceListF Macro
' Comments
'
' Keyboard Shortcut: Ctrl+f
'
 
'Move the header to right
Range("A1").Select
Selection.Cut
Range("e1").Select
ActiveSheet.Paste
 
Range("A2").Select
Selection.Cut
 
 
 
'Delete the old (now empty) leftmost column
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
 
 
Columns("c:c").Select
Selection.Delete Shift:=xlToLeft
 
 
'Open up the description column
With Columns(3)
.EntireColumn.AutoFit
.ColumnWidth = .ColumnWidth + 10
End With
 
'AutoFormat the UsedRange
ActiveSheet.UsedRange.Select
With Selection
.AutoFormat Format:=xlRangeAutoFormatList1, Number:=True, Font:=False, Alignment:=False, Border:=True, Pattern:=False, Width:=False
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
End With
End With
 
 
 
 
'Modify this format
Range("c1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Font
.Name = "Arial"
.Size = 49
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
 
 
End With
 
 
 
 
'Modify this format
Range("b1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Font
.Name = "Arial"
.Size = 24
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Rows("1:1").Select
With Selection
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Interior.ColorIndex = xlNone
End With
 
 
 
 
 
'Set up the print to fill the page
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.BlackAndWhite = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
Application.Dialogs(xlDialogPrint).Show
 
End Sub


any ideas?
Thank you
 
Last edited by a moderator:
Hi,

Just use the following code to insert image in a Excel Sheet.

Dim Img As Bitmap
Img = Image.FromFile("C:\WINNT\Prairie Wind.bmp")
System.Windows.Forms.Clipboard.SetDataObject(Img, True)
Dim str As String = "C:\WINNT\Prairie Wind.bmp"
WrkSheet.Paste(WrkSheet.Range("A10"), str)

I think this should work.

Regards

Dnyan :)
 
Back
Top