Link to home
Start Free TrialLog in
Avatar of Vadim Rapp
Vadim RappFlag for United States of America

asked on

How to remove hidden object from Word template?

If I open attached template test.dot and look at Control Toolbox / Design Mode / Properties, there's object named BarcodeSN22User generated image
How to remove it?
test.dot
Avatar of Rgonzo1971
Rgonzo1971

Hi,

pls try

Sub macro()
Dim shp
Dim inshp
For Each shp In ActiveDocument.Shapes
    For Each inshp In shp.TextFrame.TextRange.InlineShapes
        If inshp.Field.Type = wdFieldOCX Then
            inshp.Delete
        End If
    Next
Next
End Sub

Open in new window

Regards
Avatar of Vadim Rapp

ASKER

Didn't help,  ActiveDocument.Shapes.count returns 0. Did you try it yourself?
Hi,

I'm on Word 2010 that's why my code runs on my version

Could you try ActiveDocument.InlineShapes.count or ActiveDocument.Controls.Count

Regards
inlineshapes.count = 0; Controls.Count "- object does not support this property or method". (it's Word 2003)

> I'm on Word 2010 that's why my code runs on my version

So when you open it in 2010, you see the object in ActiveDocument.Shapes?
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So the solution apparently is to open it in Word 2010, and it will be repaired. Then probably resave back in 2003, if needed.