Toon posts:

[vb] Vanuit access naar word. incl pictures.

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik heb het al voor elkaar met de volgende code.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Dim db As DAO.Database
   Dim rs As DAO.Recordset
   Dim plaat As Variant
   
   Set db = CurrentDb()
   Set rs = db.OpenRecordset("Select plaatje from objecten")
   If rs.RecordCount > 0 Then
      Set plaat = rs(0)
    End If
    
   
   Dim objWord As Word.Application
   'Start Microsoft Word.
   Set objWord = CreateObject("Word.Application")
   With objWord
    ' Make the application visible.
    .Visible = True
    ' Open the document.
    .Documents.Open ("c:\MCP\object.doc ")
    ' Move to each bookmark and insert text from the form.
    .ActiveDocument.Bookmarks("titel").Select
    .Selection.Text = (CStr("anton"))
    
    .ActiveDocument.Bookmarks("titel2").Select
    .Selection.Text = (CStr("marco"))
      
    .ActiveDocument.Bookmarks "plaatje").Select ''           dit werkt natuurlijk niet op deze manier.
    .Selection.Text = (CStr(plaat))

      .ActiveDocument.SaveAs "c:\MCP\test.doc"
      .ActiveDocument.Close
      
   End With
   
   Exit Sub

Het probleem is nu dat het plaatje niet goed in word terecht komt. Iemand een idee hoe het wel moet.

[edit van dusty: code tags toegevoegd]

Verwijderd

Topicstarter
Ik heb het voor elkaar met:
.ActiveDocument.Shapes.AddPicture filename:="c:\MCP\rolsticker.jpg", linktoFile:=False

Een probleem, hij komt altijd bovenaande pagina. Dat wil ik niet, ook heb ik geen zin om bij elke template de afstand van links en boven aan te geven. Hij moet eigenlijk net als bij selection.text, een selectie kunnen vervangen door een plaatje. Dit werkt echter niet met de bovenstaande methode.