Use Loadfile with Rich Text box?

  • Thread starter Thread starter Al
  • Start date Start date
A

Al

I have a basic question that I can't seem to find an
answer to anywhere... How do you load a file into a Rich
Text Box using Access 2000? I have tried the method I
found on different news groups:
RichText1.Loadfile "FileName.rtf"
This does not work and generates Run-time error '438'
Object doesn't support this property or method.
Is .Loadfile only accepted in VB and not VBA? Do I need
to add a Common Dialog Control?
Any help to point me in the right direction would be
greatly appreciated.
TIA,
Al
 
The correct syntax would be something like:
Me.RichText1.OBject.Filename = "C:\Filename.rtf"

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Thank you for your reply, Stephen. I tried that and got
the following error: Run-time error '2771' The bound or
unbound object frame you tried to edit doesn't contain an
OLE object.

Any ideas?
Al
 
If you are using the MS Rich Text ActiveX control then the code I posted
will work. What control are you using?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Thanks Stephen,
Yes, I am using the MS ActiveX control but I continue
getting the OLE error; just not sure why. Will this not
work on the Open Event, maybe? Here is the complete code
I have:

Private Sub Report_Open(Cancel As Integer)
Dim Pth As String
Pth = [Forms]![frmWord].Report
Me.RichText1.Object.FileName = Pth
End Sub

Where 'Pth' variable is populated with:
= "C:\Database\Security\Incs\Inc1.rtf"
Al
 
You cannot do this in a Report at runtime, period. To get around it you
will have to programmatically set the control's RTF property instead:
1) Read the disk based TextFile into a string
2) Set the control's RTF property during the section's event housing the
control.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Back
Top