Access to Word

rudymadsen

New member
Local time
Today, 06:44
Joined
Sep 3, 2004
Messages
6
I have following code in a button:

Code:
Private Sub Kommandoknap33_Click()

On Error GoTo errorHandler
    
    Dim wordApp As Object ' Erklær variablen til referencen.
    Set wordApp = CreateObject("word.application")
    wordApp.Visible = True
    wordApp.documents.Open "C:\data\skabelon.doc"            
    KontaktpersonFornavn.SetFocus
    wordApp.documents(1).bookmarks("navn").range = IIf(IsNull(KontaktpersonFornavn.Text), "", KontaktpersonFornavn.Text)
    KontaktpersonEfternavne.SetFocus
    wordApp.documents(1).bookmarks("efternavn").range = IIf(IsNull(KontaktpersonEfternavne.Text), "", KontaktpersonEfternavne.Text)
    KontaktpersonAdresse1.SetFocus
    wordApp.documents(1).bookmarks("adresse").range = IIf(IsNull(KontaktpersonAdresse1.Text), "", KontaktpersonAdresse1.Text)
    KontaktpersonPostnr.SetFocus
    wordApp.documents(1).bookmarks("postnr").range = IIf(IsNull(KontaktpersonPostnr.Text), "", KontaktpersonPostnr.Text)
    Kombinationsboks24.SetFocus
    wordApp.documents(1).bookmarks("by").range = IIf(IsNull(Kombinationsboks24.Text), "", Kombinationsboks24.Text)
     
    wordApp.documents(1).SaveAs "C:\data\Output.doc"            
       
    Set wordApp = Nothing ' programmet. Frigør derefter referencen.
    
    Exit Sub
    
errorHandler:
    MsgBox Err.Number & " : " & Err.Description
    Exit Sub
End Sub

[CODE] 

How can I finaly set the cursor at a specific bookmark in the word document.

And how can I in the code format the text from my database.

Hope it's understandble...  ;)
 

Users who are viewing this thread

Back
Top Bottom