View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Find All Embedded Objects in Workbook

Andi,

Public Function CleanLines(argXLFileName As String, argSaveFolder As String,
Optional argPW As String = "") As Long
Dim xlFile As Workbook
Dim XLWS As Worksheet
Dim i As Long
Dim LineToGo As Shape
Dim LineCount As Long

Application.ScreenUpdating = False
On Error Resume Next
Set xlFile = Workbooks.Open(argXLFileName, False, True, , argPW)
If Err.Number < 0 Then
CleanLines = -1
Application.ScreenUpdating = True
Exit Function
End If
For Each XLWS In xlFile.Worksheets
If XLWS.Name < "Costings" Then
'XLWS.Activate
For Each LineToGo In XLWS.Shapes
With LineToGo
If .Type = msoLine Then
'Add a Select case if you are looking for other objects
'but for me it is only msoLine
.Delete
LineCount = LineCount + 1
End If
End With
Next
End If
Next
xlFile.SaveAs argSaveFolder & xlFile.Name, , argPW
xlFile.Close
Set xlFile = Nothing
Application.ScreenUpdating = True
CleanLines = LineCount
End Function

NickHK


"Andibevan" wrote in message
...
Thanks for the offer Nick - would it be possible to post the routine onto
here?

"NickHK" wrote in message
...
Andi,
I have the same requirement as colleague routinely add 2500~5000 minute
lines to workbooks, then deny having done anything at all.

I have a routine that will "clean" all files in a directory and save to
another directory. Bit rough and ready but I can send it to you if you

wish.

NickHK

"Andibevan" wrote in message
...
I have a problem with a worksheet saving and from reading things on

the
MS
KB it appears to be related to Embedded Objects, with the only

suggested
solution being to delete them.

The problem I have is that my colleagues have a habit of making an

embedded
object minute rather than deleting it. As a result I can't find the
mysterious embedded object.

How can I cycle through all the embedded objects on a worksheet?

TIA

Andi