Re: create rtf document with VBA




"insomniux" <dispose02@xxxxxxxxxxxxxx> wrote in message
news:4619b678-e4ac-4360-b2cd-d5686e34f820@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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

OK, a couple of things. First, if you use the RTF control, then you don't
need to create a file at all. That was my point. You can create your
formatted text using the RTF control, and then use the clipboard to transfer
to a new (unsaved) Word doc, which the user can then save or not.

Second, regarding what you wrote above, not sure why you need to leave the
doc open. Why not open in Word, copy to clipboard, close the doc, create a
new doc and paste. (Or, better still: create the doc, and then have Word
import the doc into a new, unsaved doc.) Either way, you shouldn't have to
leave it open.

You can also use API functions to get the temp directory and use that
instead. And you can also use the date/time as part of a filename, or just a
random number, so as to ensure the filename is unique.

But, all of that is moot if you use the RTF control, since you wouldn't have
to write to a file in the first place.

Neil


.



Relevant Pages

  • Re: create rtf document with VBA
    ... there are ways to do it without saving it to disk. ... You want to bring RTF codes into Word, ... To do it without saving to disk, you need to use an RTF control. ... FMS has a rich textbox control. ...
    (comp.databases.ms-access)
  • Re: create rtf document with VBA
    ... You want to bring RTF codes into Word, ... Currently I've solved it by saving the document to disk, ... To do it without saving to disk, you need to use an RTF control. ... FMS has a rich textbox control. ...
    (comp.databases.ms-access)
  • Re: create rtf document with VBA
    ... You want to bring RTF codes into Word, ... Currently I've solved it by saving the document to disk, ... To do it without saving to disk, you need to use an RTF control. ... FMS has a rich textbox control. ...
    (comp.databases.ms-access)
  • Re: RTF text box
    ... inquiries here as to the use of my RTF control. ... You will find very few threads on how to use my control that I ... developers and frankly of no use to non programmers. ... support and control shortcomings I was actually interested in your ...
    (microsoft.public.access.formscoding)
  • OLE Objects in Rich Edit control
    ... Does anybody have any experience with the EN_OBJECTPOSITIONS notification ... I am trying to load an RTF containing the "\objattph" placeholder into an ... sure the control parent will receive the ... Am I mistaken in believing that the RTF control will then use my ...
    (microsoft.public.win32.programmer.ui)