create rtf document with VBA

create rtf document with VBA

am 29.11.2007 21:08:21 von insomniux

Hi,
I use access 2000 on WinXP
In an MsAccess module I've a variable which contains an ascii text
which could form a valid RTF document. Now I want my module to create
a new instance of MsWord which shows the RTF document. I've managed to
create a Word document with the following code:

On Error Resume Next

Set Ap = GetObject(, "Word.Application")

If Ap Is Nothing Then

Set Ap = CreateObject("Word.Application")

End If

On Error GoTo 0


Set Doc = Ap.Documents.Add(template:="Normal.dot")


Doc.Activate


If I now add the rtf-formatted text, I get (as expected) the ascii
code.
I'm sure I could find the solution in the help text of MsAccess and
VBA, but for some reason Microsoft does not want to install the help
texts correctly on my PC. So I'm stuck.

Could someone please give me the clue to create the new-rtf-formatted
file? Preferably the file need not to be saved on disk (first).
Thanks a lot.
Insomniux

Re: create rtf document with VBA

am 29.11.2007 21:17:59 von BobH

Hi,
Have you looked at the Docmd.OutputTo command? it might get you what
you want
DoCmd.OutputTo , "rptname", acFormatRTF, "path/name to store output",
True

bobh.

On Nov 29, 3:08 pm, insomniux wrote:
> Hi,
> I use access 2000 on WinXP
> In an MsAccess module I've a variable which contains an ascii text
> which could form a valid RTF document. Now I want my module to create
> a new instance of MsWord which shows the RTF document. I've managed to
> create a Word document with the following code:
>
> On Error Resume Next
>
> Set Ap = GetObject(, "Word.Application")
>
> If Ap Is Nothing Then
>
> Set Ap = CreateObject("Word.Application")
>
> End If
>
> On Error GoTo 0
>
> Set Doc = Ap.Documents.Add(template:="Normal.dot")
>
> Doc.Activate
>
> If I now add the rtf-formatted text, I get (as expected) the ascii
> code.
> I'm sure I could find the solution in the help text of MsAccess and
> VBA, but for some reason Microsoft does not want to install the help
> texts correctly on my PC. So I'm stuck.
>
> Could someone please give me the clue to create the new-rtf-formatted
> file? Preferably the file need not to be saved on disk (first).
> Thanks a lot.
> Insomniux

Re: create rtf document with VBA

am 29.11.2007 21:22:54 von insomniux

I thought this command exports an existing report to disk (and
optionally opens Winword). I do not have an existing report I could
use, instead I have a variable in a module.
Thanks for your suggestion
Insomniux


On 29 nov, 21:17, bobh wrote:
> Hi,
> Have you looked at the Docmd.OutputTo command? it might get you what
> you want
> DoCmd.OutputTo , "rptname", acFormatRTF, "path/name to store output",
> True
>
> bobh.
>
> On Nov 29, 3:08 pm, insomniux wrote:
>
> > Hi,
> > I use access 2000 on WinXP
> > In an MsAccess module I've a variable which contains an ascii text
> > which could form a valid RTF document. Now I want my module to create
> > a new instance of MsWord which shows the RTF document. I've managed to
> > create a Word document with the following code:
>
> > On Error Resume Next
>
> > Set Ap = GetObject(, "Word.Application")
>
> > If Ap Is Nothing Then
>
> > Set Ap = CreateObject("Word.Application")
>
> > End If
>
> > On Error GoTo 0
>
> > Set Doc = Ap.Documents.Add(template:="Normal.dot")
>
> > Doc.Activate
>
> > If I now add the rtf-formatted text, I get (as expected) the ascii
> > code.
> > I'm sure I could find the solution in the help text of MsAccess and
> > VBA, but for some reason Microsoft does not want to install the help
> > texts correctly on my PC. So I'm stuck.
>
> > Could someone please give me the clue to create the new-rtf-formatted
> > file? Preferably the file need not to be saved on disk (first).
> > Thanks a lot.
> > Insomniux

Re: create rtf document with VBA

am 30.11.2007 00:15:21 von DM McGowan II

"insomniux" wrote in message
news:b599f4df-5bcc-4f6f-8892-d719d61c3fb8@w28g2000hsf.google groups.com...
> Hi,
> I use access 2000 on WinXP
> In an MsAccess module I've a variable which contains an ascii text
> which could form a valid RTF document. Now I want my module to create
> a new instance of MsWord which shows the RTF document. I've managed to
> create a Word document with the following code:
>
> On Error Resume Next
>
> Set Ap = GetObject(, "Word.Application")
>
> If Ap Is Nothing Then
>
> Set Ap = CreateObject("Word.Application")
>
> End If
>
> On Error GoTo 0
>
>
> Set Doc = Ap.Documents.Add(template:="Normal.dot")
>
>
> Doc.Activate
>
>
> If I now add the rtf-formatted text, I get (as expected) the ascii
> code.
> I'm sure I could find the solution in the help text of MsAccess and
> VBA, but for some reason Microsoft does not want to install the help
> texts correctly on my PC. So I'm stuck.
>
> Could someone please give me the clue to create the new-rtf-formatted
> file? Preferably the file need not to be saved on disk (first).
> Thanks a lot.
> Insomniux

First, note that you won't find a lot of help with working with RTF. I just
completing implementing an RTF system in my database, and, believe me, any
online help is scant.

Anyway, to answer your question, all you need to do is write your RTF codes
to a text file using the WRITE command, but give it the extension .RTF or
..DOC. When you open the text file containing RTF codes in Word, it will
convert your codes to a Word doc.

If you want your RTF codes to be converted to a true Word doc (as opposed to
just being displayed in Word), then you would need to execute a SaveAs in
Word after you open you file and select Word as the format.

Does that answer what you need? If not, then let me know.

Neil

Re: create rtf document with VBA

am 30.11.2007 07:48:32 von insomniux

On Nov 30, 12:15 am, "Neil" wrote:
> "insomniux" wrote in message
>
> news:b599f4df-5bcc-4f6f-8892-d719d61c3fb8@w28g2000hsf.google groups.com...
>
>
>
> > Hi,
> > I use access 2000 on WinXP
> > In an MsAccess module I've a variable which contains an ascii text
> > which could form a valid RTF document. Now I want my module to create
> > a new instance of MsWord which shows the RTF document. I've managed to
> > create a Word document with the following code:
>
> > On Error Resume Next
>
> > Set Ap = GetObject(, "Word.Application")
>
> > If Ap Is Nothing Then
>
> > Set Ap = CreateObject("Word.Application")
>
> > End If
>
> > On Error GoTo 0
>
> > Set Doc = Ap.Documents.Add(template:="Normal.dot")
>
> > Doc.Activate
>
> > If I now add the rtf-formatted text, I get (as expected) the ascii
> > code.
> > I'm sure I could find the solution in the help text of MsAccess and
> > VBA, but for some reason Microsoft does not want to install the help
> > texts correctly on my PC. So I'm stuck.
>
> > Could someone please give me the clue to create the new-rtf-formatted
> > file? Preferably the file need not to be saved on disk (first).
> > Thanks a lot.
> >Insomniux
>
> First, note that you won't find a lot of help with working with RTF. I just
> completing implementing an RTF system in my database, and, believe me, any
> online help is scant.
>
> Anyway, to answer your question, all you need to do is write your RTF codes
> to a text file using the WRITE command, but give it the extension .RTF or
> .DOC. When you open the text file containing RTF codes in Word, it will
> convert your codes to a Word doc.
>
> If you want your RTF codes to be converted to a true Word doc (as opposed to
> just being displayed in Word), then you would need to execute a SaveAs in
> Word after you open you file and select Word as the format.
>
> Does that answer what you need? If not, then let me know.
>
> Neil

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

Re: create rtf document with VBA

am 30.11.2007 14:05:07 von DM McGowan II

"insomniux" wrote in message
news:9a966782-3afe-4b0d-9c31-93d9d26efb41@w40g2000hsb.google groups.com...
> On Nov 30, 12:15 am, "Neil" wrote:
>> "insomniux" wrote in message
>>
>> news:b599f4df-5bcc-4f6f-8892-d719d61c3fb8@w28g2000hsf.google groups.com...
>>
>>
>>
>> > Hi,
>> > I use access 2000 on WinXP
>> > In an MsAccess module I've a variable which contains an ascii text
>> > which could form a valid RTF document. Now I want my module to create
>> > a new instance of MsWord which shows the RTF document. I've managed to
>> > create a Word document with the following code:
>>
>> > On Error Resume Next
>>
>> > Set Ap = GetObject(, "Word.Application")
>>
>> > If Ap Is Nothing Then
>>
>> > Set Ap = CreateObject("Word.Application")
>>
>> > End If
>>
>> > On Error GoTo 0
>>
>> > Set Doc = Ap.Documents.Add(template:="Normal.dot")
>>
>> > Doc.Activate
>>
>> > If I now add the rtf-formatted text, I get (as expected) the ascii
>> > code.
>> > I'm sure I could find the solution in the help text of MsAccess and
>> > VBA, but for some reason Microsoft does not want to install the help
>> > texts correctly on my PC. So I'm stuck.
>>
>> > Could someone please give me the clue to create the new-rtf-formatted
>> > file? Preferably the file need not to be saved on disk (first).
>> > Thanks a lot.
>> >Insomniux
>>
>> First, note that you won't find a lot of help with working with RTF. I
>> just
>> completing implementing an RTF system in my database, and, believe me,
>> any
>> online help is scant.
>>
>> Anyway, to answer your question, all you need to do is write your RTF
>> codes
>> to a text file using the WRITE command, but give it the extension .RTF or
>> .DOC. When you open the text file containing RTF codes in Word, it will
>> convert your codes to a Word doc.
>>
>> If you want your RTF codes to be converted to a true Word doc (as opposed
>> to
>> just being displayed in Word), then you would need to execute a SaveAs in
>> Word after you open you file and select Word as the format.
>>
>> Does that answer what you need? If not, then let me know.
>>
>> Neil
>
> 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

Re: create rtf document with VBA

am 30.11.2007 14:34:01 von insomniux

On 30 nov, 14:05, "Neil" wrote:
> "insomniux" wrote in message
>
> news:9a966782-3afe-4b0d-9c31-93d9d26efb41@w40g2000hsb.google groups.com...
>
>
>
> > On Nov 30, 12:15 am, "Neil" wrote:
> >> "insomniux" wrote in message
>
> >>news:b599f4df-5bcc-4f6f-8892-d719d61c3fb8@w28g2000hsf.goog legroups.com...
>
> >> > Hi,
> >> > I use access 2000 on WinXP
> >> > In an MsAccess module I've a variable which contains an ascii text
> >> > which could form a valid RTF document. Now I want my module to create
> >> > a new instance of MsWord which shows the RTF document. I've managed to
> >> > create a Word document with the following code:
>
> >> > On Error Resume Next
>
> >> > Set Ap = GetObject(, "Word.Application")
>
> >> > If Ap Is Nothing Then
>
> >> > Set Ap = CreateObject("Word.Application")
>
> >> > End If
>
> >> > On Error GoTo 0
>
> >> > Set Doc = Ap.Documents.Add(template:="Normal.dot")
>
> >> > Doc.Activate
>
> >> > If I now add the rtf-formatted text, I get (as expected) the ascii
> >> > code.
> >> > I'm sure I could find the solution in the help text of MsAccess and
> >> > VBA, but for some reason Microsoft does not want to install the help
> >> > texts correctly on my PC. So I'm stuck.
>
> >> > Could someone please give me the clue to create the new-rtf-formatted
> >> > file? Preferably the file need not to be saved on disk (first).
> >> > Thanks a lot.
> >> >Insomniux
>
> >> First, note that you won't find a lot of help with working with RTF. I
> >> just
> >> completing implementing an RTF system in my database, and, believe me,
> >> any
> >> online help is scant.
>
> >> Anyway, to answer your question, all you need to do is write your RTF
> >> codes
> >> to a text file using the WRITE command, but give it the extension .RTF or
> >> .DOC. When you open the text file containing RTF codes in Word, it will
> >> convert your codes to a Word doc.
>
> >> If you want your RTF codes to be converted to a true Word doc (as opposed
> >> to
> >> just being displayed in Word), then you would need to execute a SaveAs in
> >> Word after you open you file and select Word as the format.
>
> >> Does that answer what you need? If not, then let me know.
>
> >> Neil
>
> > 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

Re: create rtf document with VBA

am 30.11.2007 16:03:17 von DM McGowan II

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

Re: create rtf document with VBA

am 30.11.2007 18:42:00 von insomniux

On 30 nov, 16:03, "Neil" 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

Re: create rtf document with VBA

am 30.11.2007 23:08:58 von DM McGowan II

"insomniux" wrote in message
news:4619b678-e4ac-4360-b2cd-d5686e34f820@s12g2000prg.google groups.com...
> On 30 nov, 16:03, "Neil" 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

Re: create rtf document with VBA

am 02.12.2007 04:54:19 von DM McGowan II

"insomniux" wrote in message
news:4619b678-e4ac-4360-b2cd-d5686e34f820@s12g2000prg.google groups.com...
> On 30 nov, 16:03, "Neil" 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


I just reread your post. Misunderstood what you were saying the first time.
Anyway, if you don't want to use the built-in control because of
decprecation, then you can use Stephen Leban's control. It works fine with
Access 2000 and later versions. Anyway, glad you got at least one solution
worked out.

Neil