?
Solved

Display Word document in VB6 Application

Posted on 2011-03-16
7
Medium Priority
?
410 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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!

 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

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