By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,961 Members | 1,301 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,961 IT Pros & Developers. It's quick & easy.

How do I make an MS Word background with VBA ?

P: n/a
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 is 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.VerticalPercentScrol led = 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

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Mal
I haven't tried anything like this,
but wouldn't it be easier to make a word template with the stuff you want
and then just open a new word file from access using the template.

mal.
"Ronny Sigo" <ro********@skynet.be> wrote in message
news:40**********************@feed0.news.be.easyne t.net...
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 is 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.VerticalPercentScrol led = 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

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.