I try start up word from Access by VBA and use this code:
Code:
Dim objWord As Word.Application
Dim bigDoc As Word.Document
Dim WordHeaderFooter As HeaderFooter
If IsAppRunning("Word.Application") Then Set objWord = GetObject("Word.Application") Else Set objWord = CreateObject("Word.Application")
Set bigDoc = objWord.Documents.add
objWord.Visible = True
With bigDoc
.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "Alle registrerede data vedr. PersonId: " & _
Me.PersonID & " " & HentFMENavn(Me.PersonID)
.Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = "Dokumentet er sammensat pr. " & _
StrConv(Format(Date, "dddd"), vbProperCase) & " den " & Date
End With
When Word is NOT running it works fine !
When word is running (not document open) is gives me bad syntaks:
???????? Where is my screendump, it was here when I wrote the message ??????
What is wrong here ?
EDIT: It seems like ONLY this is needed:
Set objWord = GetObject(, "Word.Application")