OLE Insert Object - Word Doc

steve-oc

Registered User.
Local time
Today, 00:03
Joined
Aug 25, 2004
Messages
20
Hi

I have a table with a column defined as OLE - called EventCopy. When in table view or on a form with the control bound to this field I can choose Insert from the menu (or right click option) and choose Object and then MS Word Document.

How can do this 'behind the scenes'? - ideally when inserting a new record. I don't need to link to an existing Word doc just set the OLE field to be a Word doc.

I can simulate the action with a cmd btn on the form with:
Code:
    DoCmd.GoToControl "EventCopy"
    SendKeys "%IOmicrosoft word document~", True
but I'd really like to do it without opening the form at all.

Thanks
 
Are you attempting to insert an existing word document or wanting to create one and save it in the OLE field?

The norm is to have a hyperlink to the document as embedded objects really bloat the mdb in size.
 
I know about the bloat issues and usually link to external docs via Word automation but this is a bit of a one off.

So, no I don't need to link to an existing external doc.

Alternatively - I can set a form OLE control to dynamically display an external doc
Code:
Const stRoot As String = "C:\Temp\EventCopy"

Private Sub Form_Current()
Dim stFile As String
stFile = stRoot & "\ID_" & Me.EventID & ".doc"

If Dir(stFile) <> "" Then
    With Me!OLEWordDoc
        .Enabled = True
        .Locked = False
        .OLETypeAllowed = acOLEEmbedded
        .SourceDoc = stFile
        .Action = acOLECreateEmbed
        .SizeMode = acOLESizeZoom
        .Activate
    End With
Else
    MsgBox "No linked doc"
End If

End Sub
but I can't do this on a report - do you know how to?
Code:
Const stRoot As String = "C:\Temp\EventCopy"

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    Dim stFile As String
    stFile = stRoot & "\ID_" & Me.EventID & ".doc"
    
    If Dir(stFile) <> "" Then
        With Me.OLEWordDoc
            .OLETypeAllowed = acOLEEmbedded
            .SourceDoc = stFile
            .Action = acOLECreateEmbed
            .SizeMode = acOLESizeZoom
        End With
    Else
        MsgBox "No file!"
    End If

Errors on the .Action line...

Basically I either need to have the word doc in the db so I can display it on a report with other data from the db or, I can store the doc externally but then need it to be outputted on a OLE field on a report - if that makes sense?
 
So let me get this right.

You want to create am Access report that displays a word document for each record that has a word document in the OLE field?

What size of word documents are we talking about? and what does it contain?

Most importantly...Why?

And why thow up a msgbox for records with files?

Confused

David
 
You want to create am Access report that displays a word document for each record that has a word document in the OLE field?

What size of word documents are we talking about? and what does it contain?

Ok, there's a DB of scheduled events - date/time, venue, etc. Each event has a bit of, say 100 word, descriptive text associated with it (what the event is about - programme copy). This needs to be formatted as per MS Word - bold italic, etc. Then I need to output the event date/time, venue data with the corresponding descriptive text on an Access rpt.

So either

a. I store the descriptive text externally and get it onto the rpt or

b. store it in a OLE in the database (actually in a different db as a linked table to the main one).

In case b. When users create new events I would like to automate the insertion of the MS Word Document object in the OLE field instead of having them right click choose Insert Object, etc. I can automate the creation of external word files in case a. without a problem.

And why thow up a msgbox for records with files?
It msgbox's if there _isn't_ a corresponding doc - it's test code.
 
So basically you need text that is formatted such as enbolding, itallics, underlines, etc. That being the case why not use a Rich Text formatted ActiveX control to handle the formatting. There are many posts on that.

Only trying to save you time and effort.

Another technique would be to create a form that collected the data about the individual schedules one task at a time. Then add an option group or tick boxes to the form to act as formatting tags. Your table would need at least one extra field to store the tag information in it.

TagInfo

2 = Normal
4 = Bold
8 = Ittalic
16 = underline
32 = Bold Underline
64 = Bold Ittalic
etc

Then when the report is run a select case runs on the description field and set the appropriate intellisense to the control

select case taginfo
case 4
.Desecription.FontBold = true
case 8
.Desecription.FontIttalic = true
etc

The only problem with this is you want part of a string bold or ittalic. This would only work on the wholel text.

This idea is aircode and untested.


David



David
 
The problem with OLE is that is essentially a photo (image) of the document formatted as a bitmap hence the bloating effect.

This a bit white stick as I've only tried this on the web with html text files and not binary file but I use File System Object. As I said I've not had to use this in Access but essentially the FSO trickles the file onto the page. The trick here is it referentially access the file.

Simon
 

Users who are viewing this thread

Back
Top Bottom