Results 1 to 2 of 2

Thread: help inserting image in Excel

  1. #1
    madmakis is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.0 (VS 2002)
    Join Date
    Jun 2006
    Posts
    1
    Reputation
    0

    help inserting image in Excel

    i'm trying to insert an image on the top of the excel

    the code im using is

    Code:
     
    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 JohnH; 06-07-2006 at 7:30 PM. Reason: code box

  2. #2
    dtkubal is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    Jul 2006
    Posts
    1
    Reputation
    0

    Lightbulb

    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 AsString = "C:\WINNT\Prairie Wind.bmp"
    WrkSheet.Paste(WrkSheet.Range("A10"), str)

    I think this should work.

    Regards

    Dnyan

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking