When launched from Access via VBA, Word open a .tmp file outside the trusted folder (maybe OLE problem)

Lauro Colasanti 101 Reputation points
2023-11-25T22:38:03.6133333+00:00

Hi,

I have an Access form with an OLE BoundObjectFrame holding Word documents.

I repurpose the context menu so I can lauch the Word document by my VBA code.

When a file is opened everything is fine. But when I try to open a second one without closing the first one, Word stop the opening of the file because it's ouside of trusted folders.

But that is not the file path I launched!

I never experieced something similar in earlier versions of Office. Now I'm using Microsoft 365.

Any hint? Thanks

immagine

Word
Word
A family of Microsoft word processing software products for creating web, email, and print documents.
834 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,882 questions
Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
876 questions
Word Management
Word Management
Word: A family of Microsoft word processing software products for creating web, email, and print documents.Management: The act or process of organizing, handling, directing or controlling something.
921 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Jiajing Hua-MFST 9,760 Reputation points Microsoft Vendor
    2023-11-27T02:53:43.3866667+00:00

    Hi @Lauro Colasanti

    For newer versions of Office, Microsoft has made some changes to improve the security of VBA.

    • I suggest you go to Word > File > Options > Trust Center > Trust Center Settings > Protected View, untick the box of 'Enabled Protected View for files located in potentially unsafe locations' for a check.
    • Besides, you may check the VBA code. Here is a similar thread 'Temporary Word File in ..\INetCache\Content.Word are not trusted - is back', in the comments at the bottom, Leon Pri-Mor said modifying the code to solve this problem.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

  2. Lauro Colasanti 101 Reputation points
    2023-11-27T11:59:02.13+00:00

    Hi,

    Thanks for your help, but it didn't solve my problem.

    The Word > File > Options > Trust Center > Trust Center Settings > Protected View > 'Enabled Protected View for files located in potentially unsafe locations" is unticked but the notice is still there.

    But what seems even more strange is that the notice will appear also if I allow all macros!

    And what surprise me is that if I lauch only one file everything is allright. The notice will appear only if I lauch a second file!

    Lauro

    0 comments No comments

  3. Lauro Colasanti 101 Reputation points
    2023-11-27T18:59:30.5333333+00:00

    Hi, some update.

    If the Word files in the Ole BoundObjectFrame of Access are opened using the normal double click inside the control everything it's fine.

    If the Word files are opened by the following simple VBA code, the first file opens correctly, the second one rises the security warnings.

    The code:

    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
    
    
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.