How to fix bookmarks in word does not work in win 11 / o365?

glennford

New member
Local time
Today, 09:24
Joined
Mar 1, 2023
Messages
4
I am encountering strange problem when using windows 11 displaying bookmarks in microsoft word from msaccess. Bookmarks simply don't display any data while it does work perfectly when I'm on windows 10. I'm using office 365 here are some snippets of the code:



Dim appWord As Word.Application



Dim doc As Word.Document



Dim x as string



x = "someFoo"



On Error Resume Next Err.Clear



'Set appWord object variable to running instance of Word.



Set appWord = GetObject(, "Word.Application")



If Err.Number <> 0 Then Set appWord = New Word.Application



End



If Set doc = appWord.Documents.Open(Application.CodeProject.Path & "\profile.docx ", , True)



With doc



.FormFields("txtName").Result = x

.Visible = True



.Activate



End With



Set doc = Nothing



Set appWord = Nothing



microsoft word in always prompts in protected view when using windows 11. any solutions?
 
is your doc (docx) already in Trusted Location? you should.
 
i tried to copy your code and found some error on this line:

On Error Resume Next Err.Clear
...
...
If Set doc = appWord.Documents.Open(Application.CodeProject.Path & "\profile.docx ", , True)

should be:

On Error Resume Next
Err.Clear
...
...
Set doc = appWord.Documents.Open(Application.CodeProject.Path & "\profile.docx ", , True)
 
also here:

If Err.Number <> 0 Then Set appWord = New Word.Application



End

should be:

If Err.Number <> 0 Then Set appWord = New Word.Application
 
you remove this line:

On Error Resume

so that you will See What error you have in your code.
 
Code:
Private Sub t()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim x As String

x = "someFoo"

On Error Resume Next
Err.Clear

'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")

If Err.Number <> 0 Then Set appWord = New Word.Application

'If Set doc = appWord.Documents.Open(Application.CodeProject.Path & "\profile.docx ", , True)
Set doc = appWord.Documents.Open(Application.CodeProject.Path & "\profile.docx ", , True)

With doc
    '.FormFields("txtName").Result = x
    .Range.Bookmarks("txtName").Range.Text = x
End With
With appWord
    .Visible = True
    .Activate
End With

Set doc = Nothing

Set appWord = Nothing
End Sub
 
Tried it all in vain, and reinstalled office 365 but none seemed to work. Here's an attachment that works without issues in windows 10.
Can anybody try this on windows 11? because I tried it in multiple pcs but none seemed to worked.

My questions are:
Do legacy bookmarks have compatibility issues when running in windows 11 or are not anymore recommended?
Do I need to switch to content controls?
Or are there better solutions out there that will work with office 365 windows 11?
 

Attachments

see and test
 

Attachments

unfortunately the problem persists.

The reason I was stuck with legacy controls is it is handy especially with pre-printed forms. Is this the dead end or are there any resolutions that will not put to waste document templates I created with legacy controls?
 

Attachments

  • 334911043_658314906060867_5007678127272199613_n.png
    334911043_658314906060867_5007678127272199613_n.png
    79 KB · Views: 103
Or are there better solutions out there that will work with office 365 windows 11?
there is, create a Report in Access (see demoReport).
also you can use Bookmark for your control (open Form1 for demo of both Report and Word docx).
 

Attachments

Users who are viewing this thread

Back
Top Bottom