Your technology certification is waiting. Enroll in Cloud Class ®
Public Function DisplayDoc(ctlDocControl As Control, strDocPath As Variant) As String
On Error GoTo Err_DisplayDoc
Dim strResult As String
Dim strDatabasePath As String
Dim intSlashLocation As Integer
.Visible = True
.Enabled = True
.Locked = False
' Specify what kind of object can appear in the field.
.OLETypeAllowed = acOLELinked
' Class statement--optional for Excel worksheet.
.Class = "Microsoft Word Document"
.SourceDoc = strDocPath
.Action = acOLECreateLink
' Optional size adjustment.
.SizeMode = acOLESizeZoom
strResult = "Document found and displayed."
DisplayDoc = strResult
Select Case Err.Number
Case 2101 ' Can't find the picture.
ctlDocControl.Visible = False
strResult = "Can't find document."
Case Else ' Some other error.
MsgBox Err.Number & " " & Err.Description
strResult = "An error occurred displaying document."
Open in new window
Dim strWordDoc As String
Dim ctl As Access.Control
' or use the Common dialog to selct the new doc
strWordDoc = "C:\YourPathName\YourFileName.docx"
Set ctl = Me.ctlOleDoc 'chang the OLE object nam accordingly
DisplayDoc ctl, strWordDoc
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.