Forum Moderators: phranque

Message Too Old, No Replies

VB6 + Excel

loading images from Excel

         

giggle

5:16 am on Dec 30, 2005 (gmt 0)

10+ Year Member



Hi

Our broker has just started supplying rate sheets in Excel format for us to populate our database.

I've written a VisualVasic function to extract the data and put it directly online, but the problem I'm having is getting the pictures from the Excel sheet. When I try and get the picture using .cells() it just returns a null field (I was hoping for a path to map to).

Does anyone have any idea how to pick up the location to the image so that I can put it online?

Thanks

Mick

michaelAUS

5:47 am on Dec 30, 2005 (gmt 0)

10+ Year Member



try this?

Dim xlApp As Excel.Application
Dim wb As Workbook
Dim ws As Worksheet
Dim var As Variant
Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Open(path & "\" & file.Name)
Set ws = wb.Worksheets("<worksheet name>p")
cellvalue = ws.Range("C1").Value

or you may have to use the OLEObjects (ws.OLEObjects)
if it is a pmb,gif etc?

giggle

6:15 am on Dec 30, 2005 (gmt 0)

10+ Year Member



Thanks for the quick reply michaelAUS, unfortunately that doesn't seem to work for me.

When I click on the image the Fx= line shows:

=EMBED("Paint.Picture","")

Not much of a clue I suppose.

Strange.

Mick

michaelAUS

6:30 am on Dec 30, 2005 (gmt 0)

10+ Year Member



not a problem,

try this.. it may give you a idea:

Sub OLEObjectValueReturn()

'Return any or all OLEObjects values on active worksheet to active worksheet
Dim oleObj As OLEObject

For Each oleObj In ActiveSheet.OLEObjects
If TypeOf oleObj.Object Is MSForms.HTMLText Then
' MsgBox "HTMLText: " & oleObj.Object.Value
ActiveCell.Value = oleObj.Object.Value
ActiveCell.Offset(1, 0).Select
End If
Next

End Sub

Have a good year, whats left of it!

giggle

6:47 am on Dec 30, 2005 (gmt 0)

10+ Year Member



Woa.

Thanks for your assistance again, michaelAUS.

I think that I've been throwing you a curve ball.

When I click on the image and drag it across the screen it's clear that the image isn't actually sitting in a cell, but has been positioned over the cell. When I drag it away there's actually nothing in the cell!

Those guys are not making life easy for me.

Thanks again, and happy new year. Soon be time for the pub here in Bangkok. Can't wait!

All the best

Mick