Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Automating word documents from C#

Automating word documents from C#

Scheduled Pinned Locked Moved C#
questioncsharpdatabase
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marix
    wrote on last edited by
    #1

    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

    M H 2 Replies Last reply
    0
    • M Marix

      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

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      Why don't you show them in a RichTextBox if they are i RTF format ? With its LoadFile() function you can show stream of data. Mazy No sig. available now.

      1 Reply Last reply
      0
      • M Marix

        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

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        If this is only RTF, you could use System.Text.Encoding.ASCII or System.Text.Encoding.Unicode (depending on how the RTF is stored) to convert to byte[] array to text and assign it to the RichTextBox.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-----

        M 1 Reply Last reply
        0
        • H Heath Stewart

          If this is only RTF, you could use System.Text.Encoding.ASCII or System.Text.Encoding.Unicode (depending on how the RTF is stored) to convert to byte[] array to text and assign it to the RichTextBox.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-----

          M Offline
          M Offline
          Marix
          wrote on last edited by
          #4

          thenx you both, it really helped me a lot. I do not know but I forgot about such a thing as RichTextBox!!:)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups