Solved

Display Word document in VB6 Application

Posted on 2011-03-16
7
369 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
Comment Utility
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
Comment Utility
I tried this:
Set objWordDoc = objWordApp.Documents.Open(strMailMergeFilePath,  Visible = True)

And still does not see the document opened
0
 

Author Comment

by:Aquarus
Comment Utility
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
Comment Utility
Thanks. That's good news. Good luck with the rest of your project.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now