I included a Word DOCX file as a companion file. How do I open it?

 

It’s possible to include any file as a companion file: XLS Padlock will embed it into the secure application EXE file and make it available at runtime.

However, external applications are not allowed to access companion files for security reasons. For instance, if you added a DOCX file as a companion, a Word process started with CreateObject("word.Application") won’t find the companion file.

 

The solution consists in copying the DOCX file to a temporary location and then opening it.

 

Sub OpenWord()

Set wordapp = CreateObject("word.Application")

FileCopy PathToCompiledFile("PADLOCKPLEASEOPENME.docx"), Environ("temp") & "\PADLOCKPLEASEOPENME.docx"

wordapp.documents.Open Environ("temp") & "\PADLOCKPLEASEOPENME.docx"

wordapp.Visible = True

End Sub

 

The PathToCompiledFile macro has been defined in the topic about Companion Files.

 


Copyright © 2021 G.D.G. Software