Insert logo

S

Senad Isanovic

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
 
J

Jean-Guy Marcil

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
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

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?
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
S

Senad Isanovic

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.
 
J

Jean-Guy Marcil

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
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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