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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Word Document and insert into an OLE BoundItem 1

Status
Not open for further replies.

Hap007

MIS
Mar 21, 2003
1,018
US
Hi,

I am trying to automate a process in VBA where I create a Word Document and then store the Word Document into an OLEBoundItem control on an Open form, tied to a datafield in the recordset

I Can create the Word Doc with no problem, but so far, I can only get the word document into the OLE control by saving the document to disk and then reading the disk copy into the OLE item.

I am trying to make this a cleaner process

What I want to do is copy the active word document into the OLE item without the 'writing and reading to/from disk.

It seems I should be able to do this, but so far, no luck

Any Suggestions?

Thanks,
Hap

Access Developer [pc] Access based Accounting Solutions - with free source code
Access Consultants forum
 
I have never seen that done, the approach you are using by saving to a temp location on disk is the usual technique. If using 2007 or later I would strongly recommend to save as an attachment field to reduce database bloating. However, that still requires temp saving to disk, loading it, then deleting from disk.
 
I have never seen that done
To be more specific, I have searched for a way to do this and never found a way to do it. All the solutions I have found suggest reading and writing to disk.
 
You can leverage the clipboard:

For Word:

Selection.WholeStory
Selection.Copy

Then, for Access:

OLEBound1.Action = acOLEPaste
 
Hi Strongm

That did the trick.

It seems that if it were an Excel Sheet, I could have created the Excel Sheet by setting the OLE.Class = "Excel.Sheet"
and then using this code:
With ctl
' Enable control.
.Enabled = True
' Set Locked property to False.
.Locked = False
' Allow embedded objects only.
.OLETypeAllowed = acOLEEmbedded
' Specify the OLE server and the type of object.
.Class = "Excel.Sheet"
' Create an embedded object.
.Action = acOLECreateEmbed
End With

But I could not find a class for the Word Document

If anyone knows what the equivilant Class value for Word Doc, that would be great

Star to you

Hap...

Access Developer [pc] Access based Accounting Solutions - with free source code
Access Consultants forum
 
can you post your final code, and consider making a FAQ if one does not exist.
 
I would be happy to Post the code.

I am still working out the kinks.

In a nutshell, I am creating a Word file which is a contract.
The client wants the word contract to be produced from the information in the database
There can be minimal changes to the final document after it is created programatically
So, that is why I need to store the final word document in a database that I can lock and preserve the original contents.
I am worried about DB bloat, but my work around is to create a second Back end DB to hold just the Word Doc files.
I need to make it easy to use yet secure or I fear the users will not follow through.
To solve the problem of authenticating the document, I insert a QR Code scan able images with key document values.

So, I am working out the kinks, but should have it all working soon.

The last part was getting the document into the DB and also display on the screen without needing the user to do any type of insert object or drag and drop.

Once it is all working, I will back out the client specific code and post the rest.

Hap...

Access Developer [pc] Access based Accounting Solutions - with free source code
Access Consultants forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top