How to create a Word Background from VBA?

R

Ronny Sigo

Hello all,
I want to create a new word document from VBA (Access). All goes well,
except that I also want to establish a background programmatically. So I
made a macro in MS WORD, to see how it's done and then pasted the macrolines
in my code, but it does not work ... (those are the "ActiveDocument" lines
below ....)
Does anyone know how to do this ?
Thanks ...
Ronny

Private Sub btnEmailknop_Click()

' Hier begint Word

Dim appWD As Object
Dim myDoc As Object
Dim nHowmuchdown As Integer
Dim Spatie As Integer
Dim iLijn As Integer
Dim nAantallijnen As Integer
Set appWD = CreateObject("Word.Application")

appWD.Visible = True

With appWD
'.Resize Width:=768, Height:=552
Set myDoc = .Documents.Add
.WindowState = wdWindowStateMaximize
With .Selection
.ParagraphFormat.LeftIndent = 0
.PageSetup.LeftMargin = 80
.PageSetup.RightMargin = 52
.PageSetup.TopMargin = 127
.ParagraphFormat.LineSpacing = 13
.Font.Name = "Arial"
.Font.Size = 10
.insertafter Text:=sDatum & vbCr
End With
.Activate

For iLijn = 1 To 10
SendKeys "{UP}"
Next iLijn
'.WindowState = wdWindowStateMaximize
myDoc.ActiveWindow.ActivePane.VerticalPercentScrolled = 10
End With
ActiveDocument.Background.Fill.Visible = msoTrue
ActiveDocument.Background.Fill.ForeColor.RGB = RGB(255, 255,
255)
ActiveDocument.Background.Fill.Transparency = 0#
ActiveDocument.Background.Fill.UserPicture _
"K:\1. Management\1.7. ICT\1.7.3.
Applicaties\Taken\Beelden\logo_ZW_cbv.jpg"
End Sub
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Ronny,

You should create a template with the background already set up in it and
then create a new document from that template using

Set myDoc = Documents.Add("Path\TemplateName")

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 

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