Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9628
  • Last Modified:

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
0
RalphOrtiz
Asked:
RalphOrtiz
  • 3
  • 2
1 Solution
 
RalphOrtizAuthor Commented:
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
0
 
RalphOrtizAuthor Commented:
To TheLearnedOnel, thanks well appreciated.
0
 
Computer101Commented:
PAQed with points refunded (125)

Computer101
EE Admin
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
mouthpearCommented:
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
0
 
mouthpearCommented:
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.
0
 
RalphOrtizAuthor Commented:
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
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now