Automation error un specifed error

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:
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")
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Did you ever find a solution? I am having the exact same issue with a similar line of code which was working for the longest time but suddenly stopped. Here is the section that is highlighted upon Debugging the error...

Code:
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _
    "Data Source=MyPath;"
 
Last edited by a moderator:
Upvote 0
Did you replace a literal path with MyPath or is that supposed to be a variable?
 
Upvote 0
OK. I don't actually think this is the same issue as the original question though as it's a totally different function.

What is the path to - a database, workbook, text file, other?
 
Upvote 0
OK. I don't actually think this is the same issue as the original question though as it's a totally different function.

What is the path to - a database, workbook, text file, other?


Alright well I apologize for hijacking a thread then. I ended up getting past the line and was hung up later on in the code. The culprit being that I was closing the excel workbook I was referencing in my code in excel and then coming back to outlook and it having no object to work with.

Thanks for your time!
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top