Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export OLE object to Word

Status
Not open for further replies.

aaahhhrrggghhhh

Programmer
Apr 5, 2002
61
IE
Hi.

Hope someone can help here.

I have a table table1 :

ID Autonumber
Obj OLE Object

And have created a form for this table. I can drag and drop documents into the ole object fine. Its great, however, I need to seek further functionality.

The reason I am researching this is because I need to look into wether the following steps are possible :

1. User creates a mail merge main document in word (maybe not even set it as a mailmerge, but creates the bulk of the letter), eg :

'-----------------------------------------------

-customername-
-customeraddress-

-todaysdate-

Dear -customername-

Thank you for your application, further details will follow

yours sincerely
-usernamedesc-

'-----------------------------------------------

2. The user drag and drops that word document into a form called "media", which assigns a code to the letter and SETS IT AS A MAILMERGE**. The data source could be selected by the user before the word document is dropped in (maybe by standard data source text in combo box).

**This is my problem

3. The user goes to the project applications table, selects a project, and can see (through the use of a subform), what letters have been sent to whom, and when.

possible layout for subform :

letter date sent Username
------ --------- --------

Acceptance Leeter A2G 02-10-2002 ANNE SMITH -REVIEW-

(where REVIEW is a button)

4. The user could click on the review button, and the system would open word and insert the text for the letter, with the filled-in bits and pieces.


OK, so I have the form Form1 (this is just a test database at the moment, purely for research, so names are not a big prob).

The form looks like such :

ID : ------------

Obj : |-----------------------------------|
| |
| My OLE Object |
|-----------------------------------|

------------------------------
DataSourceCB : |"All Project Data"-------|\/| (Combo Box)
------------------------------
|------|
| But1 |
|------|

when I press button 1, the system needs to take the text in Obj (which is actually a Word Document, dragged in), and :

1. Make sure its a main document (ie that it has a datasource). If not, create one based on the selection in DataSourceCB, which will point to a table. The actual value that DataSourceCB will be bound to will contain an SQL statement, such as :

Select * from Applicants where [Sent Letter] = 0

But the entries will read ("Standard Project List", "Standard Payment List", and so on)

(probably not exactly like that, but thats not what I'm asking for, just want to give you an idea of how I'm tackling this problem so far)

2. Take the text in the Obj OLE Object and open it in word, using the selected (via DataSourceCB) SQL statement as a datasource and run the mailmerge.


The whole point to this is so that the database handles all the mail merging, the user just drops in the main document into a form, the system assigns that letter a code, then the user selects that the letter needs to be generated for whatever projects it needs to be generated for, then, it goes off and does it.

I hope that my explanation of my problem is clear enough. I know that its long, but I wanted to make doubly sure that I am getting my message accross properly.

Again, hope someone can help.

At the moment, I only have fragments of code (the remmed out stuff has been tested, but not work):


Private Sub Command7_Click()

'take the connection string in me.ConnectionStringTableUsed, and turn the current object in
'obj into a mailmerge document

If IsNull(Me.ConnectionStringTableUsed) Then Exit Sub

'otherwise, use it
Dim oApp As New Word.Document

Set oApp = Word.Documents.Add(Me.Obj.Value, , "Word.Document", True)

With oApp

' .Content = Me.Obj.Value

.SetLetterContent (Me.Obj.Value)
.Activate
End With

' Me.Obj.Class = ("Word.Document")
' MsgBox (Me.Obj.Class)
' Debug.Print Me.Obj.Object

' oApp.MailMerge.OpenHeaderSource Me.Obj.Value

' Dim myoleobj As Word.MailMergeDataSource
' Set myoleobj = oApp.MailMergeDataSource

' Debug.Print Mid$(oApp.MailMerge.DataSource.ConnectString, 1, 1000)

' oApp.MailMerge.OpenDataSource "C:\my_be.mdb", wdOpenFormatAuto, False, True, False _
, False, , , False, , , " applicantid = 2000016482", , , False

' oApp.MailMerge.DataSource.QueryString = "Select * from Applications where applicantid = 2000016482"

' myddeguid = oApp.DDEInitiate("C:\Program Files\Microsoft Office\Office10\Winword.exe", "Open Document")
' oApp.DDEPoke myddeguid, "Document Concerned", Me.Obj
' oApp.Visible = True

MsgBox ("OK")


End Sub

Dont be small. be BIG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top