Link to home
Start Free TrialLog in
Avatar of RalphOrtiz
RalphOrtizFlag for United States of America

asked on

Inserting image file into Excel cell using VB6

I having problems placing a image file into excel 2007 cell.  I using the same routine which works well with excel 2003 and below.  When I place the image in Excel 2007 the image is place in the center of the cell which requires the end user to manually move the image to the upper right hand corner of cell A1.

sample code.    
   
    oXLApp.Range("A1").Select
    oXLApp.Range("A1").RowHeight = 59.25
    oXLApp.Range("A1").Select
    Delay 3
    oXLApp.ActiveSheet.Pictures.Insert("C:\asl.gif").Select
Avatar of RalphOrtiz
RalphOrtiz
Flag of United States of America image

ASKER

Thanks to anyone who is trying to figure it out bu I was able to come up with solution for those who are having the same issue.  I added the following.

    oXLApp.Range("A1").Select
    oXLApp.Range("A1").RowHeight = 59.25
    Delay 1
    Set ce = oXLApp.Range("A1", oXLApp.Cells(oXLApp.Rows.Count, 1))
    oXLApp.ActiveSheet.Pictures.Insert("C:\ASL.GIF").Select
    oXLApp.Selection.ShapeRange.Top = ce.Top
    oXLApp.Selection.ShapeRange.Left = ce.Left
To TheLearnedOnel, thanks well appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mouthpear
mouthpear

I can not remember where I got this code but I may help you. Let me know?
Private Sub Worksheet_Calculate()
        Dim oPic As Picture
        Me.Pictures.Visible = False
        With Range("F1")
            For Each oPic In Me.Pictures
                If oPic.Name = .Text Then
                    oPic.Visible = True
                    oPic.Top = .Top
                    oPic.Left = .Left
                    Exit For
                End If
            Next oPic
        End With
    End Sub

Open in new window

Lookup-Pic-example.xls
Oh and I would like to have what code you have, I am having the opposite problem I have 2007 and want my pix to center lol.
I used this code to insert an image into Excel 2007.  The following places the image and adjust
oXLApp.Selection.ShapeRange.Top = ce.Top
    oXLApp.Selection.ShapeRange.Left = ce.Left