Automating word documents from C#
-
I am new to office development so I have a question. I have a database where rtf files are stored in image filed. From my application I need to show this rtf document in word application. I think I have to use office application PIA's. One solution would be to save this image filed (rtf document) in some temp directory but then I would not be able to delete this file becouse I would not know when the user would stop using it. So is there a way I can open this image field (rtf file as System.Byte[]) in word application not saving it before on physical drive? thenx a lot
-
I am new to office development so I have a question. I have a database where rtf files are stored in image filed. From my application I need to show this rtf document in word application. I think I have to use office application PIA's. One solution would be to save this image filed (rtf document) in some temp directory but then I would not be able to delete this file becouse I would not know when the user would stop using it. So is there a way I can open this image field (rtf file as System.Byte[]) in word application not saving it before on physical drive? thenx a lot
-
I am new to office development so I have a question. I have a database where rtf files are stored in image filed. From my application I need to show this rtf document in word application. I think I have to use office application PIA's. One solution would be to save this image filed (rtf document) in some temp directory but then I would not be able to delete this file becouse I would not know when the user would stop using it. So is there a way I can open this image field (rtf file as System.Byte[]) in word application not saving it before on physical drive? thenx a lot
If this is only RTF, you could use
System.Text.Encoding.ASCII
orSystem.Text.Encoding.Unicode
(depending on how the RTF is stored) to convert tobyte[]
array to text and assign it to theRichTextBox.Rtf
property. If you need to use Word instead, you'll have to save this to a temporary file. The only way to load a stream is with a structured storage document, which RTF isn't (only compound documents like Word Documents are). Since you would be using the Office PIAs, however, you'll have to create an instance of Word.Application. Since you have that reference, you can attach events to know when the application is closed, or even if a document is closed. In this event handler, you can delete the temporary file.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
If this is only RTF, you could use
System.Text.Encoding.ASCII
orSystem.Text.Encoding.Unicode
(depending on how the RTF is stored) to convert tobyte[]
array to text and assign it to theRichTextBox.Rtf
property. If you need to use Word instead, you'll have to save this to a temporary file. The only way to load a stream is with a structured storage document, which RTF isn't (only compound documents like Word Documents are). Since you would be using the Office PIAs, however, you'll have to create an instance of Word.Application. Since you have that reference, you can attach events to know when the application is closed, or even if a document is closed. In this event handler, you can delete the temporary file.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----