Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Searching for a graphic in a header/footer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sol Apache - 10 Nov 2006 17:41 GMT
Hello

I cannot find anything in Mac VisualBasic for Word to show how I can find an
anchored graphic (a logo) and to switch its visibility on or off for
printing.

If I put the logo in a text box inline a paragraph with a unique style I can
get VB to change it to hidden text, but I cannot change it back to visible!
VB cannot find the text box, which is in the header.

Can anyone help me with the VB for either:

1. finding an anchored standalone graphic in the header (once found I change
its visibility by changing its transparency?).

Can I assign a number or name to the graphic in case the letter writer
decides to put another graphic in the main part of the letter?

or

2. finding a textbox in the header with a graphic inline with hidden text of
a specific style.

Thanks for any help.
Doug Robbins - Word MVP - 11 Nov 2006 00:49 GMT
I am not sure about doing it on a Mac, but in windows versions, you can turn
off the printing of graphics by unchecking the "Drawing objects" box under
Tools>Options>Print.  To use VBA to do that, you would use

   Options.PrintDrawingObjects = False

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hello
>
[quoted text clipped - 25 lines]
>
> Thanks for any help.
Sol Apache - 11 Nov 2006 01:52 GMT
Thanks for this. But won¹t this stop all graphics in a document from being
printed? I just want the logo to not print. It¹s unlikely that a user will
put extra graphics in the letter/document, but there will always be an
exception (as you well know).

On 11/11/06 00:49, in article u5DVGtSBHHA.1012@TK2MSFTNGP04.phx.gbl, "Doug
Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote:

> I am not sure about doing it on a Mac, but in windows versions, you can turn
> off the printing of graphics by unchecking the "Drawing objects" box under
> Tools>Options>Print.  To use VBA to do that, you would use
>
>     Options.PrintDrawingObjects = False
Martin Sägesser - 17 Nov 2006 08:53 GMT
Hi

In my documents there are shapes and inlineshapes, and I use this
procedure to change them - perhaps you can change it for your VB.

hth, Martin

'---
Sub LogoChange()
' change visibility of graphics in header

Dim ishp As InlineShape

On Error GoTo LogoChange_Err

' Bildschirm wird nicht aktualisiert
   Application.ScreenUpdating = False

' temporäre Textmarke an aktueller Stelle gesetzt
   ActiveDocument.Bookmarks.Add Name:="temp"

' Gehe zu Seite 1
   Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"

' Erste Fusszeile wird geöffnet
   ActiveWindow.ActivePane.View.Type = wdPageView
   ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageHeader

' Alle Grafiken aus oder eingeblendet
   ActiveDocument.Sections(1).Headers
(wdHeaderFooterPrimary).Shapes.SelectAll
   
   With Selection.ShapeRange.PictureFormat
       If .Brightness = 0.5 Then
           .Brightness = 1#
           .Contrast = 0#
           pubbLogos = False
       Else
           .Brightness = 0.5
           .Contrast = 0.5
           pubbLogos = True
       End If
   End With
   
   For Each ishp In ActiveDocument.Sections(1).Headers
(wdHeaderFooterFirstPage).Range.InlineShapes
       If ishp.PictureFormat.Brightness = 0.5 Then
           ishp.PictureFormat.Brightness = 1#
           ishp.PictureFormat.Contrast = 0#
       Else
           ishp.PictureFormat.Brightness = 0.5
           ishp.PictureFormat.Contrast = 0.5
       End If
   Next ishp
   
   For Each ishp In ActiveDocument.Sections(1).Headers
(wdHeaderFooterPrimary).Range.InlineShapes
       If ishp.PictureFormat.Brightness = 0.5 Then
           ishp.PictureFormat.Brightness = 1#
           ishp.PictureFormat.Contrast = 0#
       Else
           ishp.PictureFormat.Brightness = 0.5
           ishp.PictureFormat.Contrast = 0.5
       End If
   Next ishp
   
' Sprung zur temporären Textmarke, Löschen der Textmarke
   ActiveDocument.Bookmarks("temp").Select
   ActiveDocument.Bookmarks("temp").Delete

' Bildschirmaktualisierung einschalten
   Application.ScreenRefresh
   Application.ScreenUpdating = True
   Exit Sub
' wenn kein Fehler wird Sub beendet

LogoChange_Exit:
   Exit Sub
   
' Fehlerbehandlungsroutine
LogoChange_Err:
   
   If ActiveWindow.ActivePane.View.Type <> wdPageView Then
ActiveWindow.ActivePane.View.Type = wdPageView
   
   ActiveDocument.Bookmarks("temp").Select
   ActiveDocument.Bookmarks("temp").Delete
   
   If bProtect Then
       ActiveDocument.protect Password:="", Type:
=wdAllowOnlyFormFields, NoReset:=True
       bProtect = False
   End If
   
   Application.ScreenRefresh
   Application.ScreenUpdating = True
   MsgBox "Das aktuelle Dokument enthält keine Grafiken in der
Kopfzeile", vbInformation, TEXT_MSGBOX
   
   Resume LogoChange_Exit

End Sub
'---

> Thanks for this. But won¹t this stop all graphics in a document from being
> printed? I just want the logo to not print. It¹s unlikely that a user will
[quoted text clipped - 9 lines]
> >
> >     Options.PrintDrawingObjects = False
Sol Apache - 22 Nov 2006 17:29 GMT
Hello

Thanks for this. I’ll get someone to translate the German then I can test it
out.

Sol

On 17/11/06 08:53, in article MPG.1fc796e1d4f85f2198968a@news.post.ch,

> Hi
>
[quoted text clipped - 113 lines]
>>>
>>>     Options.PrintDrawingObjects = False
Martin Sägesser - 23 Nov 2006 07:39 GMT
Hi Sol

I was hoping the commands were enough to understand it... translation
see below!

Martin

> Hello
>
[quoted text clipped - 21 lines]
> >
> > ' Bildschirm wird nicht aktualisiert
' stop screen updating
> >     Application.ScreenUpdating = False
> >
> > ' temporäre Textmarke an aktueller Stelle gesetzt
' temporary bookmark to mark actual position
> >     ActiveDocument.Bookmarks.Add Name:="temp"
> >
> > ' Gehe zu Seite 1
' goto first page
> >     Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
> >
> > ' Erste Fusszeile wird geöffnet
' open first header
> >     ActiveWindow.ActivePane.View.Type = wdPageView
> >     ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageHeader
> >
> > ' Alle Grafiken aus oder eingeblendet
' view/hide all pictures
> >     ActiveDocument.Sections(1).Headers
> > (wdHeaderFooterPrimary).Shapes.SelectAll
[quoted text clipped - 34 lines]
> >    
> > ' Sprung zur temporären Textmarke, Löschen der Textmarke
' goto temporary bookmark and delete bookmark
> >     ActiveDocument.Bookmarks("temp").Select
> >     ActiveDocument.Bookmarks("temp").Delete
> >
> > ' Bildschirmaktualisierung einschalten
' activate screen updating
> >     Application.ScreenRefresh
> >     Application.ScreenUpdating = True
> >     Exit Sub
> > ' wenn kein Fehler wird Sub beendet
' terminate sub when no error

> > LogoChange_Exit:
> >     Exit Sub
> >    
> > ' Fehlerbehandlungsroutine
' error handling
> > LogoChange_Err:
> >    
[quoted text clipped - 4 lines]
> >     ActiveDocument.Bookmarks("temp").Delete
> >    
Delete this part, this is only for documents with protection...
> >     If bProtect Then
> >         ActiveDocument.protect Password:="", Type:
> > =wdAllowOnlyFormFields, NoReset:=True
> >         bProtect = False
> >     End If
delete end :-)
> >    
> >     Application.ScreenRefresh
> >     Application.ScreenUpdating = True

MsgBox "No Picture found in Header", vbInformation, TEXT_MSGBOX

> >     MsgBox "Das aktuelle Dokument enthält keine Grafiken in der
> > Kopfzeile", vbInformation, TEXT_MSGBOX
[quoted text clipped - 17 lines]
> >>>
> >>>     Options.PrintDrawingObjects = False

Signature

Martin Sägesser
martin(at)sibs.ch

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.