View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] paul.robinson@it-tallaght.ie is offline
external usenet poster
 
Posts: 789
Default Type Mismatch Error

Hi
I don't think worksheets or even workbooks have a picture object. Try
Shape in the Shapes class (this may pick up comments and buttons
however).

regards
Paul

On Apr 29, 12:14*pm, Sarah (OGI)
wrote:
I'm getting a type mismatch error, at the point of 'For Each pic In
wsSource.Pictures' in the following code - any ideas why this might be?

=============
Sub CopyAllPictures()
Dim r As Long, c As Long
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Dim pic As Picture

Set wsSource = Workbooks("test.xls").Worksheets("Summary")
Set wsDest = Worksheets("PC (Chart)-NI-MONTH")

r = wsSource.Rows.Count
c = wsSource.Columns.Count

For Each pic In wsSource.Pictures
With pic.TopLeftCell
If .Row < r Then r = .Row
If .Column < c Then c = .Column
End With
Next

wsDest.Activate
wsDest.Cells(r, c).Activate

wsSource.Pictures.Copy
wsDest.Paste

wsDest.Cells(r, c).Activate

End Sub
============