Hi,
I have a new and very strange problem arising from Word and Access interop.
Never noticed something similar before. Now I'm using Microsoft 365
I an Access form I have only a text control where I can type the name of the word file I want to open and a buttons that opens it.
The first time I click the button everyting fine, as expected.
The second time (the first word file is still opened) the following security warning pops up.
The folder where the files are is a trusted folder!
Allowing all macro in Word Option is not useful!
The file are based on a template with only one macro.
I don't know what to think!
The code run from button click is the following:
Private Sub cmdBtWord_Click()
Dim objWordApp As Word.Application
Dim sFileName As String
sFileName = Me.txtFileName
On Error Resume Next
Set objWordApp = GetObject("Word.Application")
If Err.Number <> 0 Then Set objWordApp = CreateObject("Word.Application")
On Error GoTo 0
With objWordApp
.Visible = True
.Activate
.Documents.Open sFileName
End With
Set objWordApp = Nothing
End Sub
I have a new and very strange problem arising from Word and Access interop.
Never noticed something similar before. Now I'm using Microsoft 365
I an Access form I have only a text control where I can type the name of the word file I want to open and a buttons that opens it.
The first time I click the button everyting fine, as expected.
The second time (the first word file is still opened) the following security warning pops up.
The folder where the files are is a trusted folder!
Allowing all macro in Word Option is not useful!
The file are based on a template with only one macro.
I don't know what to think!
The code run from button click is the following:
Private Sub cmdBtWord_Click()
Dim objWordApp As Word.Application
Dim sFileName As String
sFileName = Me.txtFileName
On Error Resume Next
Set objWordApp = GetObject("Word.Application")
If Err.Number <> 0 Then Set objWordApp = CreateObject("Word.Application")
On Error GoTo 0
With objWordApp
.Visible = True
.Activate
.Documents.Open sFileName
End With
Set objWordApp = Nothing
End Sub