Hello everyone
I'm struggling and need to ask for some help. It's probably really simple,
but my brain is not coping well at all.
I have a template which deletes/retains logos according to choices made from
a user form. It's working really well, except for one scenario and that is:
I want to delete the shapes where the criteria from one list box is met, and
the criteria from the others is not. And I've reached a mental block! The
code should be something like the "opposite" of the code below, in other
words I want to delete the logos if the text in the Combo2 box is anything
other than HR, Sales & Marketing or Product Control. Can anyone point me in
the right direction please?
Thanks for your help
Aehan
With ActiveDocument.Bookmarks("Combo1").Range
If InStr(.text, "Department 1") Then
With ActiveDocument.Bookmarks("Combo2").Range
If InStr(.text, "HR") Or InStr(.text, "Sales & Marketing")
Or _
InStr(.text, "Product Control") Then
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
With Selection.HeaderFooter
.Shapes("HR Logo").Delete
.Shapes("SM Logo").Delete
.Shapes("PC Logo").Delete
End With
End If
End With
End If
End With
Greg Maxey - 16 Nov 2007 13:23 GMT
Sub Test()
If InStr(ActiveDocument.Bookmarks("Combo1").Range.Text, "Department 1") Then
Select Case ActiveDocument.Bookmarks("Combo2").Range.Text
Case "HR", "Sales & Marketing", "Product Control"
'Do Nothing
Case Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Selection.HeaderFooter
.Shapes("HR Logo").Delete
.Shapes("SM Logo").Delete
.Shapes("PC Logo").Delete
End With
End Select
End If
End Sub

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
> Hello everyone
>
[quoted text clipped - 32 lines]
> End If
> End With
aehan - 16 Nov 2007 14:09 GMT
Hi Greg
Thank you very much for showing me how to write the code, I really
appreciate that. I've tried the code and it's not deleting the logos.
I'm running against a problem that I've been coming across all day - where
referring to a bookmark with ActiveDocument.Bookmarks("bmname").range.text
doesn't seem to read the text.
I've tried debugging using message boxes to return the value of the
bookmark, and when I step through the code - when it uses the Instr function,
it recognises the text and returns a message, but when the bookmark is
accessed by ActiveDocument.Bookmarks("test").range.text it doesn't read it
and the message box returns nothing. I'm really stuck. Do you have any
ideas? Thanks for helping me so far.
Aehan
> Sub Test()
> If InStr(ActiveDocument.Bookmarks("Combo1").Range.Text, "Department 1") Then
[quoted text clipped - 48 lines]
> > End If
> > End With
Greg Maxey - 16 Nov 2007 14:32 GMT
Sub Testing()
'Are you saying that a line like this is not working
MsgBox ActiveDocument.Bookmarks("Combo2").Range.Text
'But if the bmrange text contained "bmtext" then this condition is met?
If InStr(ActiveDocument.Bookmarks("Combo2").Range.Text, "bmtext") Then
MsgBox "Text read"
End If
End Sub
If so then I really don't know what to tell you.
What happens when you step through the code I sent to you?

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
> Hi Greg
>
[quoted text clipped - 74 lines]
>>> End If
>>> End With
aehan - 16 Nov 2007 15:16 GMT
Hi Greg
It's worked!!!! I don't know what I did wrong the first time I put your
code in, but now it's excellent. I just took it slowly and worked it through
without panicking this time. Thank you very much for your help, wish I could
give you a medal!
Aehan
> Sub Testing()
> 'Are you saying that a line like this is not working
[quoted text clipped - 87 lines]
> >>> End If
> >>> End With
Greg Maxey - 16 Nov 2007 19:12 GMT
Medals I have. I might consider work for food though ;-)

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
> Hi Greg
>
[quoted text clipped - 98 lines]
>> >>> End If
>> >>> End With