Hello guru's
I have a problem.
I am using a VBA script which worked fine when I used office 2003.
This script was created by my colleague how has left the building so to speak.
I myself have no experience with macro's / VBA scripts.
When we switched to Excel 2010 it seemed to run fine but with the difference that the images were no longer copied to the worksheet.
Only a shortcut is added to the cell(s).
When I e-mail the worksheet the receiver cannot see the images which where added.
I can see the images in the excel document but only when the t:\ drive is available.
If I disconnect this network drive then I have the same problem.
Below is the code:
Sub InsertPicInRange()
'
' InsertPicInRange Macro
' De macro is opgenomen op 24-6-2005 door sb.
'
' Sneltoets: CTRL+SHIFT+Q
'
Dim strRange As String
Dim strRange2 As String
strRange = "A12"
For I = 12 To 200
strRange = "A" & I
strRange2 = "B" & I & ":" & "B" & I
InsertPictureInRange "t:\" & Worksheets("Offerte").Range(strRange), _
Range(strRange2)
Next I
End Sub
Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range)
' inserts a picture and resizes it to fit the TargetCells range
Dim p As Object, t As Double, l As Double, w As Double, h As Double
If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
If Dir(PictureFileName) = "t:\" Then Exit Sub
If Right(PictureFileName, 4) <> ".jpg" Then PictureFileName = PictureFileName + ".jpg"
'import picture
On Error GoTo JUMPNEXT
Set p = ActiveSheet.Pictures.Insert(PictureFileName)
GoTo ENDSTATEMENT
JUMPNEXT:
PictureFileName = "T:\" & Right(PictureFileName, 10)
If Not IsNull(p) Then GoTo FIN Else GoTo ENDSTATEMENT
ENDSTATEMENT:
' determine positions
'On Error GoTo FIN
With TargetCells
t = .Top
l = .Left
w = .Offset(0, .Columns.Count).Left - .Left
h = .Offset(.Rows.Count, 0).Top - .Top
End With
' position picture
With p
.Top = t
.Left = l
.Width = w
.Height = h
End With
Set p = Nothing
FIN:
End Sub
Does anyone have an anwser to this problem?
Bookmarks