How do I make an MS Word background with VBA ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ronny Sigo

    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 programmaticall y. 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_Cl ick()

    ' 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("W ord.Application ")

    appWD.Visible = True

    With appWD
    '.Resize Width:=768, Height:=552
    Set myDoc = .Documents.Add
    .WindowState = wdWindowStateMa ximize
    With .Selection
    .ParagraphForma t.LeftIndent = 0
    .PageSetup.Left Margin = 80
    .PageSetup.Righ tMargin = 52
    .PageSetup.TopM argin = 127
    .ParagraphForma t.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 = wdWindowStateMa ximize
    myDoc.ActiveWin dow.ActivePane. VerticalPercent Scrolled = 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\Tak en\Beelden\logo _ZW_cbv.jpg"
    End Sub



  • Mal

    #2
    Re: How do I make an MS Word background with VBA ?

    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" <ronnysiigo@sky net.be> wrote in message
    news:40040235$0 $1116$6c56d894@ feed0.news.be.e asynet.net...[color=blue]
    > 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 programmaticall y. So I
    > made a macro is MS WORD, to see how it's done and then pasted the[/color]
    macrolines[color=blue]
    > 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_Cl ick()
    >
    > ' 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("W ord.Application ")
    >
    > appWD.Visible = True
    >
    > With appWD
    > '.Resize Width:=768, Height:=552
    > Set myDoc = .Documents.Add
    > .WindowState = wdWindowStateMa ximize
    > With .Selection
    > .ParagraphForma t.LeftIndent = 0
    > .PageSetup.Left Margin = 80
    > .PageSetup.Righ tMargin = 52
    > .PageSetup.TopM argin = 127
    > .ParagraphForma t.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 = wdWindowStateMa ximize
    > myDoc.ActiveWin dow.ActivePane. VerticalPercent Scrolled = 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\Tak en\Beelden\logo _ZW_cbv.jpg"
    > End Sub
    >
    >
    >[/color]


    Comment

    Working...