Answered by:
Access Forms OLE control Docx file how-to show up one per record

Question
-
Hello,
I have 5000 records, and 5000 short word docx files, I want to show in a form, into a OLE control, the docx file.
The table is (id, name, olefield)
How can I link the field record type OLE to every file named like "name" ? I prefer incrust the file more than link. It´s diffuclt.
Any help please ?
Programador .NET
- Edited by PlatinumRunner Friday, October 6, 2017 9:08 PM
Friday, October 6, 2017 8:58 PM
Answers
-
Hello,
Do you want to create a table like:
So in the form, FileName shows the file name and OLEField shows contents of the document.
You may use the following code:
Private Sub Command11_Click() 'add reference "Microsoft Office X.0 Object Model" Dim fDialog As Office.FileDialog Dim varFile As Variant Set fDialog = Application.FileDialog(msoFileDialogFolderPicker) With fDialog .Title = "Please select one folder" If .Show = True Then sFile = Dir(.SelectedItems(1) & "\" & "*.docx") Do Until sFile = "" Me.FileName = sFile Me.OLEField.OLETypeAllowed = acOLEEmbedded Me.OLEField.SourceDoc = .SelectedItems(1) & "\" & sFile Me.OLEField.Action = acOLECreateEmbed DoCmd.Save DoCmd.GoToRecord , , acNewRec sFile = Dir Loop DoCmd.GoToRecord , , acFirst Else MsgBox "You clicked Cancel in the file dialog box." End If End With End Sub
Regards,
Celeste
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Marked as answer by PlatinumRunner Monday, October 9, 2017 2:45 PM
Monday, October 9, 2017 6:07 AM
All replies
-
Hi,
Not sure I am clear what you want to do. Can you show us some concrete examples of what you mean? Thanks.
Saturday, October 7, 2017 1:53 AM -
Hello,
Do you want to create a table like:
So in the form, FileName shows the file name and OLEField shows contents of the document.
You may use the following code:
Private Sub Command11_Click() 'add reference "Microsoft Office X.0 Object Model" Dim fDialog As Office.FileDialog Dim varFile As Variant Set fDialog = Application.FileDialog(msoFileDialogFolderPicker) With fDialog .Title = "Please select one folder" If .Show = True Then sFile = Dir(.SelectedItems(1) & "\" & "*.docx") Do Until sFile = "" Me.FileName = sFile Me.OLEField.OLETypeAllowed = acOLEEmbedded Me.OLEField.SourceDoc = .SelectedItems(1) & "\" & sFile Me.OLEField.Action = acOLECreateEmbed DoCmd.Save DoCmd.GoToRecord , , acNewRec sFile = Dir Loop DoCmd.GoToRecord , , acFirst Else MsgBox "You clicked Cancel in the file dialog box." End If End With End Sub
Regards,
Celeste
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Marked as answer by PlatinumRunner Monday, October 9, 2017 2:45 PM
Monday, October 9, 2017 6:07 AM -
Hello Celeste, thank for your help.
FIrst one, I need a form, while moving next and back show up a word.docx file.
I created a new field, a text one, and I save there the path of that field, but the showing up is so slow, every time the form move next redcord, last 2 second, I wanted to incrust the docx file as OLE at onece (all 5000 files) and then move back and forward fast, I mean to show the docx in just a 0.5 second, no the 2-3 lasting now.
I adapated a code that every time the user move next and back in the form (with a boundobjectframe crontrol, the one will display a word.docx file), open the file and incrust it in the boundobjectframe (one ole control) to show the file in the form.
It´s clear, something, else, I found that if I save the file docx in the OLE data field by hand, to show it in Windows 10 (1703) and Access 2016, it is not possible, not yet resolved my Microsoft, I mean I have to reread the docx file and show up by code, there is no autoupdate of the control in the form everytime I move next/back record, Do you have the same problem ?
Anyway, thank you very much your help, I will test your code.
Programador .NET
Monday, October 9, 2017 2:44 PM