ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   problems with importing an image (https://www.excelbanter.com/excel-discussion-misc-queries/128224-problems-importing-image.html)

Todd

problems with importing an image
 
we have an intranet page that links up with Excel. it passes a whole bunch of
info using fields and then Excel displays it all. The intranet has its own
server.

If I'm using a workstation everything runs fine, however, if I'm working on
our main server the image does not load properly.

Now the details.....

the field that gets passed to Excel has a value like this: "\\ipaddress of
intranet server\folder\file.gif"

when excel opens the following script runs:


Private Sub Workbook_Open()
Dim myPict As Picture
Dim curWks As Worksheet
Dim myRng As Range
Dim myCell As Range
Dim myPictName As Variant



Set curWks = Sheets(1) ' Change to suit

'curWks.Pictures.Delete

With curWks
Set myRng = .Range("B57")
End With


If Trim(myRng.Cells.Value) = "" Then
'do nothing
ElseIf Dir(CStr(myRng.Cells.Value)) = "" Then
'picture not there!
'MsgBox myRng.Cells.Value & " Doesn't exist!"
Else
With myRng.Cells.Offset(0, 1) '3 columns to the right of C (F)
Set myPict = myRng.Cells.Parent.Pictures.Insert(myRng.Cells.Val ue)
myPict.Top = .Top
myPict.Width = .Width
myPict.Height = .Height
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With
End If



End Sub


The script will break at this point:

ElseIf Dir(CStr(myRng.Cells.Value)) = "" Then
'picture not there!
'MsgBox myRng.Cells.Value & " Doesn't exist!"



The value of the field gets inserted into a specific cell and displays as a
link - visually theres nothing wrong with that data or the link, however, if
you try it you get a message that says it cant find the server.

After playing around with that link (trying different ways to write it - but
with no success) I changed it back to the original way it was and it all of a
sudden it worked (sort of) for one specific instance. By "sort of" I mean
that I still got an error from the script telling me it couldnt find the
image and if i clicked on the link it threw the "couldnt find the server"
error - even though the image was right there on the page. Add to the fact
that I had just changed it back to the original way it was written so, in
reality, I didnt change anything at all - and i couldnt repeat the miracle
either.

Again, I can go to any workstation and get this procedure to run fine but
only when I try and do this on our main server does it give me problems. both
the workstations and the server run Excel 2003. The workstations run IE7 and
the server still runs IE6. XP for the worksations and 2003 for the server.

I've tried to explain this as best i could with out getting too long winded
about the whole thing. If I've left anything out I apologize and would be
happy to provide more info.

Thank you very much

TB


All times are GMT +1. The time now is 06:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com