[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

Display Word document in VB6 Application

Database type:SQL 2008  
Table1.Field1 datatype (image)
Before the record is written into Table 1 the Mail Merge process is being run, i.e Stored procedure provides the recordset that is stored in Excel table from where the data is merged into the Word Template .doc.

At the end the information about this particular Mail Merge is stored in the Table1 with one of the fields(Field1) populated with image of the created word document.  The data in the Field1 looks like this:
...58E2AF7704ACB128C71A9F126EFA0DF7868B2987F819A6E1B9B7C3DB8D842399458F74819F749F8EF8777AC98E8EDE887C9CD39B49C9696EDE0B74...

I need to redisplay the document for the user again  based on the unique Id of the particular record from Table1. I can not re-run the mailmerge process because it will re-run the stored procedure and there is a possibility that the user will have the different data in the recordset.

I need the expert advise please.
0
Aquarus
Asked:
Aquarus
  • 4
  • 3
1 Solution
 
GrahamSkanCommented:
That text is a Hex display of some data.

What do you mean by image? The display method would depend on how the image is created.
0
 
GrahamSkanCommented:
OK. I've done some research. It seems that 'Image' is the term that is used in SQL for unformatted binary data.

If seems that you load the file to the field. The simplest way to display the document again would be to open the Word file. If you have erased or overwritten it, you can save from the image field and then open it in Word:

http://www.motobit.com/tips/detpg_read-write-sql-image-file/
0
 
AquarusAuthor Commented:
I made my own research too and I found that I can actually reprint the document.  The sample I have now does it like this:
 Set objWordDoc = objWordApp.Documents.Open(strMailMergeFilePath, _
                                                                            Visible = False)

            ' Print the document & close all the open files
             
            objWordDoc.PrintOut
            objWordDoc.Close False

           While objWordApp.BackgroundPrintingStatus > 0
                DoEvents
            Wend

            objWordApp.Application.Quit

            ' Delete all the documents created for printing (local disk)
            Call DeleteFiles(strMailMergeFilePath)
           
            objStream.Close
            Set objStream = Nothing
            Set objWordApp = Nothing
            Set objWordDoc = Nothing

It actually reprints and reprints tha same doc.  I stuck on the issue, that I cannot actually open the word document to display.  I.E Cannot find the usable method similar to  "objWordDoc.PrintOut" that works.

Am I on the wrong path of searching?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
GrahamSkanCommented:
If you have a valid word application object, and can't see it, it might be it hasn't been set to visible:

 objWordApp.Visible = True
0
 
AquarusAuthor Commented:
I tried this:
Set objWordDoc = objWordApp.Documents.Open(strMailMergeFilePath,  Visible = True)

And still does not see the document opened
0
 
AquarusAuthor Commented:
Graham, just wanted to let you know that I have created th stay-alone button, placed this set of codes in the click event and have my document previewed.  Thank you

Private Sub Command1_Click()
Dim objWordApp As Object
Dim objWordDoc As Object
   
    ' Instantiate word objects
    Set objWordApp = CreateObject("Word.Application")
    Set objWordDoc = CreateObject("Word.Document")


            ' Open the document
            Set objWordDoc = objWordApp.Documents.Open("C:\MMDoc649.doc")
            objWordApp.Visible = True
           
End Sub

I guess I'll just play arounto make the application works the way I need it to.

Thank you again
0
 
GrahamSkanCommented:
Thanks. That's good news. Good luck with the rest of your project.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now