Solved

Display Word document in VB6 Application

Posted on 2011-03-16
7
381 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 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