MarkCBB
Active Member
- Joined
- Apr 12, 2010
- Messages
- 497
Hi there,
I hope someone else has encounted this, because i am so confuzzeled.
the below code loaded pictures from a folder into the image controls, all the picture are the same format. and this works perfectly on my PC excel 2010, but the above error occours on the users pc (excel 2007) but only on some of the pictures.
Below is the error message:
Microsoft Visual Basic
run-time error'-247467259 (80004005)':
Automation error
unspecified error
the sheet has 3 image controls
here is my code:
the error happens on this line of code
I hope someone else has encounted this, because i am so confuzzeled.
the below code loaded pictures from a folder into the image controls, all the picture are the same format. and this works perfectly on my PC excel 2010, but the above error occours on the users pc (excel 2007) but only on some of the pictures.
Below is the error message:
Microsoft Visual Basic
run-time error'-247467259 (80004005)':
Automation error
unspecified error
the sheet has 3 image controls
here is my code:
Code:
Sub AddPicture()
Dim MyPictureName1 As String
Dim MyPictureName2 As String
Dim MyPictureName3 As String
Dim SHT_LIST As Worksheet
Dim SHT_FilteredOutlet_DB As Worksheet
Dim SHT_Report5 As Worksheet
Dim i As Long
Dim sFolderName As String
Set SHT_FilteredOutlet_DB = Sheet12
Set SHT_LIST = Sheet2
Set SHT_Report5 = Sheet7
i = SHT_LIST.Range("C11").Value
sFolderName = Application.DefaultFilePath & "\Executrac - Huggies Store Pictures\"
SHT_Report5.Shapes.Range(Array("Rectangle 5")).Visible = True
Application.ScreenUpdating = True
DoEvents
MyPictureName1 = SHT_FilteredOutlet_DB.Range("E4").Offset(i, 0).Value & " Front of store"
MyPictureName2 = SHT_FilteredOutlet_DB.Range("E4").Offset(i, 0).Value & " Inside of Store"
MyPictureName3 = SHT_FilteredOutlet_DB.Range("E4").Offset(i, 0).Value & " Nappies"
If Len(Dir(sFolderName & MyPictureName1 & ".png", vbDirectory)) <= 0 Then MyPictureName1 = "HUGGIES"
If Len(Dir(sFolderName & MyPictureName2 & ".png", vbDirectory)) <= 0 Then MyPictureName2 = "HUGGIES"
If Len(Dir(sFolderName & MyPictureName3 & ".png", vbDirectory)) <= 0 Then MyPictureName3 = "HUGGIES"
'error on the below line of code
SHT_Report5.OLEObjects("Image1").Object.Picture = LoadPicture(sFolderName & MyPictureName1 & ".png")
SHT_Report5.OLEObjects("Image2").Object.Picture = LoadPicture(sFolderName & MyPictureName2 & ".png")
SHT_Report5.OLEObjects("Image3").Object.Picture = LoadPicture(sFolderName & MyPictureName3 & ".png")
Application.ScreenUpdating = True
DoEvents
SHT_Report5.Shapes.Range(Array("Rectangle 5")).Visible = False
End Sub
Sub MyCodeHere()
On Error Resume Next
Call AddPicture
On Error GoTo 0
End Sub
Sub ClearPictures()
Dim SHT_Report5 As Worksheet
Set SHT_Report5 = Sheet7
SHT_Report5.OLEObjects("Image1").Object.Picture = LoadPicture("")
SHT_Report5.OLEObjects("Image2").Object.Picture = LoadPicture("")
SHT_Report5.OLEObjects("Image3").Object.Picture = LoadPicture("")
End Sub
Sub PictureNext()
Dim SHT_LIST As Worksheet
Dim SHT_FilteredOutlet_DB As Worksheet
Dim FilteredOutletRowCount As Long
Set SHT_LIST = Sheet2
Set SHT_FilteredOutlet_DB = Sheet12
FilteredOutletRowCount = WorksheetFunction.CountA(SHT_FilteredOutlet_DB.Range("D5:D1000000"))
If SHT_LIST.Range("C11").Value >= FilteredOutletRowCount Then
MsgBox ("This is the last one")
Else
SHT_LIST.Range("C11").Value = SHT_LIST.Range("C11").Value + 1
Call AddPicture
End If
End Sub
Sub PictureBack()
Dim SHT_LIST As Worksheet
Dim SHT_FilteredOutlet_DB As Worksheet
Dim FilteredOutletRowCount As Long
Set SHT_LIST = Sheet2
Set SHT_FilteredOutlet_DB = Sheet12
FilteredOutletRowCount = WorksheetFunction.CountA(SHT_FilteredOutlet_DB.Range("D5:D1000000"))
If SHT_LIST.Range("C11").Value = 1 Then
MsgBox ("This is the first one")
Else
SHT_LIST.Range("C11").Value = SHT_LIST.Range("C11").Value - 1
Call AddPicture
End If
End Sub
the error happens on this line of code
Code:
SHT_Report5.OLEObjects("Image1").Object.Picture = LoadPicture(sFolderName & MyPictureName1 & ".png")