I have a really simple bit of code that I'm trying to in Ms Access 2010. I want a control on a form to open a word document. I've tried several things but the simplest piece of code I've cobbled together is as follows:
Private Sub CmdWord_Click()
Set wordApp = GetObject(, "Word.Application")
With wordApp
.Visible = True
Set wordDoc = .Documents.Add
End With
End Sub
This compiles but when I run it without Word being open I get "run time 429 error: activex component can't create object.
With Word open I get a new document opening.
I have tried updating references to ADO 6.0 to no avail. I'm new to VBA so any help appreciated.
You can generally open a file with the registered application with FollowHyperlink.
FollowHyperlink "z:\docs\word.docx"
Otherwise, you can use CreateObject when Word is not running.
On Error Resume Next
Set oWord = GetObject(,"Word.Application")
If Err.Number <> 0 Then
Set oWord = CreateObject("Word.Application")
End If
oWord.Visible = True