How to fix bookmarks in word does not work in win 11 / o365? (1 Viewer)

glennford

New member
Local time
Today, 16:48
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?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:48
Joined
May 7, 2009
Messages
19,243
is your doc (docx) already in Trusted Location? you should.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:48
Joined
May 7, 2009
Messages
19,243
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)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:48
Joined
May 7, 2009
Messages
19,243
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:48
Joined
May 7, 2009
Messages
19,243
you remove this line:

On Error Resume

so that you will See What error you have in your code.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:48
Joined
May 7, 2009
Messages
19,243
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
 

glennford

New member
Local time
Today, 16:48
Joined
Mar 1, 2023
Messages
4
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

  • bookmark.zip
    51.6 KB · Views: 81

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:48
Joined
May 7, 2009
Messages
19,243
see and test
 

Attachments

  • db.accdb
    740 KB · Views: 90

glennford

New member
Local time
Today, 16:48
Joined
Mar 1, 2023
Messages
4
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: 73

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:48
Joined
May 7, 2009
Messages
19,243
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

  • db.accdb
    1 MB · Views: 83

Users who are viewing this thread

Top Bottom