Re: create rtf document with VBA
- From: insomniux <dispose02@xxxxxxxxxxxxxx>
- Date: Fri, 30 Nov 2007 09:42:00 -0800 (PST)
On 30 nov, 16:03, "Neil" <nos...@xxxxxxxxxx> wrote:
I've indeed noticed that RTF seems to be a dying principle (in
windows), unfortunately.
Your suggestion is probably the easiest to do, and I will probably go
that way. Drawback is that the file is saved to disk, which is in most
cases not required.
Thanks.
Insomniux
Well, there are ways to do it without saving it to disk. Why don't you
specify what, exactly, you're trying to accomplish, and maybe I can help
you
further. You want to bring RTF codes into Word, but you don't want to
save
the file? Why?
Neil
The rtf-file usually does not need to be kept. And in case the client
wants to save the document, I do not know the network-mapping of the
client, or the client may even be on a VPN without a c-drive. Too many
chances for errors.The only thing the client certainly does is: making
some modificatons and print the document. I do have the report-
template in RTF. In the report there are several repeating rows
depending on different fields in the query I draw from the database.
Currently I've solved it by saving the document to disk, but I still
prefer to do without saving.
Insomniux
To do it without saving to disk, you need to use an RTF control. The control
can be hidden; but you'll need a control to convert your RTF codes to actual
rich text.
Access has a built-in control, MS Rich Textbox, but it's been disabled in
Access 2002 and above, for security purposes. If you're using Access 2000 or
below, then use that.
FMS has a rich textbox control (which I used). But it costs $300.
Stephen Lebans, who posts here, has his own rich textbox control, which
would work fine for your purposes -- and it's free! So I would use that one
if you're in Access 2002 or above.
But, basically, you'd create an RTF control on your form, hidden if you
wish. You'd set the controls' value to your RTF codes, and then you can
select and copy the text in the control to the clipboard and paste into
Word.
Here's another way I just thought of without needing an RTF control. You say
the issue is you don't know the client's configuration. But the client will
have to be running your application from somewhere. So get the path of your
MDB file (currentproject.Path) and save a temporary file there with your
codes. Open Word in the background, and have Word open your saved file.
Select the rich text from your converted document in Word, and copy to the
clipboard. Then paste into whatever you want. Close the hidden instance of
Word, and delete your temporary file.
Not as elegant as using a rich text control, and more time consuming (have
to wait for an instance of Word to open); but it would work.
So there are a couple of approaches for you.
If you need more help, let me know.
Neil
OK, indeed various options....
I'll chose for the last one. I'm using Office 2000. I could use the
builtin-RTF control (didn't know it existed), but since it will be
deprecated, I'm a little reluctant to use it. Problem with using the
currentproject.Path, is that more than 1 user could be using the
application. My solution is:
1. at startup I'll detect the computer name in the network (I guess
that's possible)
2. create the file as textstream as [currentproject.Path]\
[computername].rtf
3. open Word with [currentproject.Path]\[computername].rtf as
template
4. before application.quit: delete [currentproject.Path]\
[computername].rtf
If the Word instance is still open at ap.quit, Access will refuse to
delete the file, but it will be deleted at a next session.
Not the most beautiful construction, but it'll probably work.
Thanks for your thoughts,
Insomniux
.
- Follow-Ups:
- Re: create rtf document with VBA
- From: Neil
- Re: create rtf document with VBA
- References:
- create rtf document with VBA
- From: insomniux
- Re: create rtf document with VBA
- From: Neil
- Re: create rtf document with VBA
- From: insomniux
- Re: create rtf document with VBA
- From: Neil
- Re: create rtf document with VBA
- From: insomniux
- Re: create rtf document with VBA
- From: Neil
- create rtf document with VBA
- Prev by Date: Re: Append Table problem
- Next by Date: Re: Append Table problem
- Previous by thread: Re: create rtf document with VBA
- Next by thread: Re: create rtf document with VBA
- Index(es):
Relevant Pages
|