473,412 Members | 5,385 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

How do I make an MS Word background with VBA ?

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
1 8336
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: provaands | last post by:
Defects of the code below: with Mozilla, Netscape, the word hellooo..... exit outside from the div; with IE 5,5, 6 the word hellooo.... increase the width of the div, even if i have fixed to...
3
by: IMS.Rushikesh | last post by:
Hi Friends, I am having a problem to set a background color of any selected Word in MS-Word. Only few default (nearly 16 colors) are allow to set as Background color in MS-Word. But i want to...
0
by: morph2007 | last post by:
Hi, I have my resume in good old HTML with Tables and CSS. I have two stylesheets, one to format for the web and the other for when I load the resume up into word - all works fine. Now - I...
0
by: Shat T. Cat | last post by:
Hello, I have a program that I originally wrote in VB6 that breaks down plain-text Profit & Loss reports from my organization's Accounting system into separate files for each Cost Center (office...
2
by: Derek Hart | last post by:
I am using late bound Microsoft Word integration with a vb.net winforms application. If I run code such as the following: Dim objWord As Object Dim objWrdDoc As Object Dim count As Integer...
0
by: vandervelde | last post by:
Hi, A couple of machines in the office have recently upgraded to word 2003 and the printing macros for these machines are working intermittently. The macro takes the computer name and a printer...
1
by: amiparna | last post by:
There is two frame in my form.In d first frame there is a text box,and i give some word in the text box.I want to search the word from a file from the location(http://45.12.09.31...........) and if...
0
by: Ang | last post by:
Hi, I want to open a word file on background instead of showing the process on client's screen. And then do mailmerge, after that allow user to saveas. (user simply click the button and IE will...
9
by: DeZZar | last post by:
Hi all, Basically I want the data in an open form to merge with a word template and create a new document. So a user navigates to a particular records and presses a button "Produce Document"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.