In-line shapes - Odd macro behaviour

R

Roderick O'Regan

The situation is as follows:
I have a document with quite a few sections.
In the footer of each section is a table of one row and three columns.
The last cell on the right of each table holds a small logo.
This logo is an in-line shape

Users might need to remove this logo at any time.

I have adapted a macro from the Word MVP site (thanks to Doug Robbins
et al) and is listed below.

It does the job for which it is intended but I have a great feeling
that it is not correctly written.

Especially so, as at the bottom I've had to use some "sticky tape and
string" tp stop the active view from going into split normal view
(this is separated by ======= marks.

The code:
Public Sub DeleteSmallGreenLogos()
Dim kStory As Word.Range
Dim kJunk As Long
Dim kShp As InlineShape
'Fix the skipped blank Header/Footer problem
kJunk = ActiveDocument.Sections(1).Footers(1).Range.StoryType
'Iterate through all story types in the current document
For Each kStory In ActiveDocument.StoryRanges
'Iterate through all linked stories
Do
On Error Resume Next
Select Case kStory.StoryType
Case wdEvenPagesFooterStory, wdFirstPageFooterStory,
wdPrimaryFooterStory
If kStory.InlineShapes.Count > 0 Then
For Each kShp In kStory.InlineShapes
If kShp.Height > CentimetersToPoints(1) And kShp.Height <
CentimetersToPoints(1.1) Then
If kShp.Width > CentimetersToPoints(2.6) And
kShp.Width < CentimetersToPoints(2.7) Then
kShp.Select
kShp.Delete
End If
End If
Next
End If
Case Else
'Do Nothing
End Select
On Error GoTo 0
'Get next linked story (if any)
Set kStory = kStory.NextStoryRange
Loop Until kStory Is Nothing
Next
================================
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
================================
End Sub

Can anyone advise, please?

Roderick
 
H

Helmut Weber

Hi Roderick,

as far as I see, you don't have to care at all about
ActiveWindow.View.SplitSpecial
ActiveWindow.ActivePane.View.Type
ActiveWindow.View.Type = wdPrintView
and others

at all, as long as you avoid the selection.

Delete kShp.Select '!

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top