Solved

Display Word document in VB6 Application

Posted on 2011-03-16
7
388 Views
Last Modified: 2012-05-11
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
Comment
Question by:Aquarus
  • 4
  • 3
7 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35151046
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35151115
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
 

Author Comment

by:Aquarus
ID: 35151249
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 35151483
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
 

Author Comment

by:Aquarus
ID: 35151674
I tried this:
Set objWordDoc = objWordApp.Documents.Open(strMailMergeFilePath,  Visible = True)

And still does not see the document opened
0
 

Author Comment

by:Aquarus
ID: 35151754
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 35151992
Thanks. That's good news. Good luck with the rest of your project.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question