Use Loadfile with Rich Text box?

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
 
S

Stephen Lebans

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.
 
A

Al

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
 
S

Stephen Lebans

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.
 
A

Al

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
 
S

Stephen Lebans

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top