Showing posts with label Add Shapes to Headers using Word VBA. Show all posts
Showing posts with label Add Shapes to Headers using Word VBA. Show all posts

Thursday, June 24, 2010

How to simulate speech Echo in VBA

The following snippet simulates ( a sort of ) the Echo effect in VBA. This uses Microsoft Speech Object Library


Sub Voice_It_Out()

Dim oVoice As SpVoice                               ' Voice Object

' --------------------------------------------------------------
' Code for http://vbadud.blogspot.com
' --------------------------------------------------------------

Set oVoice = New SpVoice


For iVol = 100 To 10 Step -10
    oVoice.Volume = iVol
    oVoice.Speak "Echo!"
Next iVol

End Sub

Monday, March 31, 2008

Adding Images to Header using VBA (Word VBA)

Use Pictures/Images in Word Document Header using Word VBA

Most often we will be using company's logo in Header. Here is the way to do it using VBA

Sub Add_File_Header()

Set docActive = Word.ActiveDocument

ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.InlineShapes.AddPicture "C:\My Documents\My Pictures\MYPicture.bmp"

docActive.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "Header text" ' ERROR

objWord.ActiveDocument.ActiveWindow.View.SeekView = wdSeekMainDocument

With docActive.PageSetup

.DifferentFirstPageHeaderFooter = False 'Set this to false will put text on first page, else will not.

End With

End Sub
Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.