Your opinion about best way to display Word documents inside an Access form

The problem you are facing is that OneDrive protocols are more limiting than a simple LAN-attached disk, network-attached disk, local disk, or disk-like USB device. It isn't so much that you have an OLE problem; it is that you have a OneDrive problem. OneDrive is a whole-file solution but Office expects/uses a protocol based on getting selected disk blocks out of the whole file.
I found in this post a solution to one of the major problem using a OLE Object Frame (Bound or Unbound) in an Access form when the file to link is in a OneDrive folder.
I didn't test extensivly, but it seems to work for me.
 
That is what the user will do!
But, maybe, after he/her gave a look to the content of one/more documents.
Then the user will simply use it to preview what document to open so he/she edits it from within Word itself, Access is just the preview tool?
If so, have you tested what arnelgp does here?

Alternatively, if all documents look roughly the same, have you tested simply using the word api to retrieve the contents and show them in access?
 
Then the user will simply use it to preview what document to open so he/she edits it from within Word itself, Access is just the preview tool?
If so, have you tested what arnelgp does here?

Alternatively, if all documents look roughly the same, have you tested simply using the word api to retrieve the contents and show them in access?
I tried to use the new Edge Browser, as Office Insider, but I cannot.
I don't understand the last suggestion
 
I found in this post a solution to one of the major problem using a OLE Object Frame (Bound or Unbound) in an Access form when the file to link is in a OneDrive folder.
I didn't test extensivly, but it seems to work for me.
After reading that linked post, I believe your solution is to find the local copy of the file used by OneDrive for staging purposes. That file is in a directory hidden (using "obscurity") to protect it in some way. That will work for changes that you make to your private i.e. non-shared file that is being stored on OneDrive - but the problem comes when the OneDrive file is actively being shared among multiple users and another user changes the file, too.

In an actively shared case, MSFT takes the other user's update and sends it up to OneDrive - which then notifies all other active participants of the update - and there is where complexities hit the fan, as OneDrive tries to overlay that local copy to match the shared file. To my understanding, there is a time window regarding how often those updates occur and you are inviting a phenomenon called "destructive interference" when taking this approach. If you are making a change to the shared file through this local copy rather than the active OneDrive mechanism, you are making a change outside the scope of the remote file mirroring that goes on with OneDrive. At this point, OneDrive does not know and cannot tell which version of the file is correct.
 
I tried to use the new Edge Browser, as Office Insider, but I cannot.
I don't understand the last suggestion
The last suggestion involves extracting the content of the file to show it in a user form. The vba code would simply declare the document, initialize it, opening it, traversing the document to extract its content and fill some text control and finally closing the document. What I meant by "if all documents look roughly the same" is that you can anticipate the structure and mimic it inside access. Would that be OK for your case?
 
The last suggestion involves extracting the content of the file to show it in a user form. The vba code would simply declare the document, initialize it, opening it, traversing the document to extract its content and fill some text control and finally closing the document. What I meant by "if all documents look roughly the same" is that you can anticipate the structure and mimic it inside access. Would that be OK for your case?
The file are not necessarily similar. And I would like to keep the whole formatting
 
And I would like to keep the whole formatting

If you want to display something inside a text box (as such), you cannot keep the formatting. An OLE window OR actually opening Word in some kind of constrained window will be required. Access is not a word processor and cannot correctly interpret Word files on its own.
 
If you want to display something inside a text box (as such), you cannot keep the formatting. An OLE window OR actually opening Word in some kind of constrained window will be required. Access is not a word processor and cannot correctly interpret Word files on its own.
That's way I cannot use the suggestion. That's way I'm try to find the best way to accomplish this through OLE or WebBrowser
 
@lauro I was waiting to see if someone gives you this suggestion.
A while back we needed to show some documents from our one drive in a form.

I'm not sure about this, but as far as I remember, we copied all the necessary files from one drive to %temp% folder in onLoad event of the form, and linked them to OLE objects or WebBrowser on the form. If users needed to edit the files, a double click opened the source file (in one drive) and let the user edit/save the file. A refresh of the form, showed the new version of the file.

We don't use this method anymore, so I can not search the exact procedure we took, but you may want to research on this.
 
@lauro I was waiting to see if someone gives you this suggestion.
A while back we needed to show some documents from our one drive in a form.

I'm not sure about this, but as far as I remember, we copied all the necessary files from one drive to %temp% folder in onLoad event of the form, and linked them to OLE objects or WebBrowser on the form. If users needed to edit the files, a double click opened the source file (in one drive) and let the user edit/save the file. A refresh of the form, showed the new version of the file.

We don't use this method anymore, so I can not search the exact procedure we took, but you may want to research on this.
Thank you KitaYama,
your suggestion is very helpful.
In my onLoad event I inserted the following code:

Me.Recordset.MoveFirst
Do While Not Me.Recordset.EOF
FileCopy OldLocation & "\" & Me.Recordset!NomeFile & ".docx", NewTempLocation & "\" & Me.Recordset!NomeFile & ".docx"
Me.Recordset.MoveNext
Loop
The transfer is fine.

But I'm facing a new problem: I'm unable to update my MYOLE control (bound or unbound) that will display the files.
  • If I use an Unbound frame, I need to update the content when navigating records: but I'm unable to change the MYOLE.SourceDoc on every Form_Current event. Is it possible to change "SourceDoc" property of an Unbound Frame Control by code or it can be done only in Design View?
  • If I use a Bound frame I tried unsuccesfully two ways:
    • Using as MYOLE.ControlSource a calculated field =GetTempLocation()+"\"+[NomeFile]+".docx", but it doesn't work, probably because it doesn't find the LONG that should stand for the Word file.
    • Adding a new non requested OLE field to the table from which my form takes tha data; and then trying to insert this field in the onLoad event while I'm doing the transfer of the file. So the previous code should have, for every record in the recordset, after the line of the FileCopy, the code to insert the Ole object in its field. But while it is simple to do it manually, I don't know how to insert by code a Word file as an OLE Object into a recordset. [or a table or a query]
Sameone can help me, please?
Thanks, Lauro
 
Last edited:
Not sure if this has already been suggested. For one of my client I receive many different types of files, some of which are Word Any file received is converted to a format that can be viewed in the web browser control (not tested edge browser yet). Appreciiate OP has looked at conversion to PDF - but required manual opening and saving or getting the original author to do it.

In the case of Word and Excel these need to be converted to a PDF - So I have code that passes the filepath and name to a function which does the necessary conversion. In the case of Word, the code is as follows:

Code:
Set app = CreateObject("Word.Application")
                Set f = app.Documents.Open(fName)
    
                f.ExportAsFixedFormat OutputFilename:=Replace(fName, fType, "pdf"), _
                                    ExportFormat:=17, _
                                    OpenAfterExport:=False, _
                                    OptimizeFor:=0, _
                                    Range:=0, _
                                    FROM:=0, _
                                    to:=0, _
                                    item:=0, _
                                    IncludeDocProps:=True, _
                                    KeepIRM:=True, _
                                    CreateBookmarks:=0, _
                                    DocStructureTags:=True, _
                                    BitmapMissingFonts:=True, _
                                    UseISO19005_1:=False

Typically it can take 2-3 seconds to do the conversion and to open the pdf in the web browser.

To date I have received several hundred word documents (.docx) and this code has never failed. It has not been tried on the old .doc style format, I'll cross that bridge if I ever come across it.
 

Users who are viewing this thread

Back
Top Bottom