M
MichaelM
I'd like to display 400 word documents in a report. In order to save
space I saved the document paths in a table as text. The documents
should be loaded dynamically via the path, while the report is
displayed.
I succeeded to display the word documents in an 'unbound object frame'
in a *form*. The code below loads and displays (as intended) the Word
document when I scroll throught the pages of the form.
Private Sub Form_Current()
'Counter to generate the postfix document name doc1.doc, doc2.doc
etc.
Static pgNo As Integer
pgNo = pgNo + 1
With Me![OLEWordDoc]
.Enabled = True
.Locked = False
.OLETypeAllowed = acOLEEmbedded
.Class = "Word.Document"
Dim path As String
Dim rootPath As String
rootPath = "c:\temp"
path = rootPath & "\w" & pgNo & ".doc"
.SourceDoc = path
.Action = acOLECreateEmbed
.SizeMode = acOLESizeZoom
End With
End Sub
My problem is however that I want to use a *report* not a *form*.
The first test was to run the code above in a report. The code was
triggered by a button in the report (only possible in Access 2007). As
intended the Word document is loaded and displayed (property .Enabled
was commented out to make it running).
If I then execute the above code in the event handler Report_Open, I
get an error message in the line '.Locked = False':
Run-time error 2455: You entered an expression that has an invalid
reference to the property Locked.
Therefore I commented out '.Locked'.
The execution then stopped the in the line '.Action =
acOLECreateEmbed' with the error message:
'Run-time error 2772 – The bound or unbound object frame you tried to
edit does not contain an OLE object'
The same error message (2772) is displayed if I use the variant:
..OLETypeAllowed = acOLELinked
..Action = acOLECreateLink
Thanks in advance
Michael
space I saved the document paths in a table as text. The documents
should be loaded dynamically via the path, while the report is
displayed.
I succeeded to display the word documents in an 'unbound object frame'
in a *form*. The code below loads and displays (as intended) the Word
document when I scroll throught the pages of the form.
Private Sub Form_Current()
'Counter to generate the postfix document name doc1.doc, doc2.doc
etc.
Static pgNo As Integer
pgNo = pgNo + 1
With Me![OLEWordDoc]
.Enabled = True
.Locked = False
.OLETypeAllowed = acOLEEmbedded
.Class = "Word.Document"
Dim path As String
Dim rootPath As String
rootPath = "c:\temp"
path = rootPath & "\w" & pgNo & ".doc"
.SourceDoc = path
.Action = acOLECreateEmbed
.SizeMode = acOLESizeZoom
End With
End Sub
My problem is however that I want to use a *report* not a *form*.
The first test was to run the code above in a report. The code was
triggered by a button in the report (only possible in Access 2007). As
intended the Word document is loaded and displayed (property .Enabled
was commented out to make it running).
If I then execute the above code in the event handler Report_Open, I
get an error message in the line '.Locked = False':
Run-time error 2455: You entered an expression that has an invalid
reference to the property Locked.
Therefore I commented out '.Locked'.
The execution then stopped the in the line '.Action =
acOLECreateEmbed' with the error message:
'Run-time error 2772 – The bound or unbound object frame you tried to
edit does not contain an OLE object'
The same error message (2772) is displayed if I use the variant:
..OLETypeAllowed = acOLELinked
..Action = acOLECreateLink
Thanks in advance
Michael