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 / December 2004

Tip: Looking for answers? Try searching our database.

Insert logo

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Senad Isanovic - 07 Dec 2004 17:23 GMT
Need a button (vba code) that inserts a logotype in a header (there is a
bookmark b in a table). When the logotype is inserted and the user clicks on
the button again it should not be inserted again. I also need the button
that will remove the picture (logotype) if the user wants to undo the insert
button. The documents can contain several pages, but the buttons should
insert / remove the logo on the first page only (regardless from where you
are in the document). Thanks for any help
Jean-Guy Marcil - 07 Dec 2004 18:58 GMT
Senad Isanovic was telling us:
Senad Isanovic nous racontait que :

> Need a button (vba code) that inserts a logotype in a header (there
> is a bookmark b in a table). When the logotype is inserted and the
[quoted text clipped - 4 lines]
> first page only (regardless from where you are in the document).
> Thanks for any help

I have a very nice wooden button I could DHL to you...

Seriously, what kind of button are you talking about? ActiveX, Toolbar,
userform, Macrobutton?

What code have you got so far?
Is the logo only visible on the first page?
What Word version?
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Senad Isanovic - 08 Dec 2004 15:43 GMT
I'm talking about button in Word toolbar that will run a macro. The code I
have so far..

   If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _

       ActivePane.View.Type = wdOutlineView Then

       ActiveWindow.ActivePane.View.Type = wdPrintView

   End If

   ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

   Selection.InlineShapes.AddPicture FileName:= _

       "C:\bilder\al425.jpg", LinkToFile:=False, SaveWithDocument:=True

I'm using Word XP.

> Senad Isanovic was telling us:
> Senad Isanovic nous racontait que :
[quoted text clipped - 16 lines]
> Is the logo only visible on the first page?
> What Word version?
Jean-Guy Marcil - 08 Dec 2004 17:09 GMT
Senad Isanovic was telling us:
Senad Isanovic nous racontait que :

> I'm talking about button in Word toolbar that will run a macro. The
> code I have so far..

Insert a bookmark (Named "logotype" in my example) in the primary header
where you want the logo to appear. Ideally it should be an empty paragraph,
otherwise we might have to modify the code.

'_______________________________________
Sub AddLogo()

Dim HeaderRange As Range
Const BookName As String = "logotype"

Set HeaderRange = ActiveDocument.Sections(1) _
   .Headers(wdHeaderFooterPrimary).Range _
   .Bookmarks(BookName).Range

With HeaderRange
   If .InlineShapes.Count = 0 Then
       .Collapse
       .InlineShapes.AddPicture _
           FileName:="C:\bilder\al425.jpg", _
           LinkToFile:=False, SaveWithDocument:=True
       Set HeaderRange = HeaderRange.Paragraphs(1).Range
       ActiveDocument.Bookmarks.Add BookName, HeaderRange
   End If
End With

End Sub
'_______________________________________

'_______________________________________
Sub RemoveLogo()

Dim HeaderRange As Range
Const BookName As String = "logotype"

Set HeaderRange = ActiveDocument.Sections(1) _
   .Headers(wdHeaderFooterPrimary).Range _
   .Bookmarks(BookName).Range

With HeaderRange
   If .InlineShapes.Count > 0 Then
       .InlineShapes(1).Delete
       Set HeaderRange = HeaderRange.Paragraphs(1).Range
       ActiveDocument.Bookmarks.Add BookName, HeaderRange
   End If
End With

End Sub
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
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.