OLE Insert Object - Word Doc


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


Sponsored Links:



Scenario:
Have a separate Access GUI front-end (local) and separate mdb (on network share)
Have a table with the following fields on the MDB:

Doc_ID>>ID
Doc_Details >> TEXT
DOC >>> OLE OBJECT

This is what will be done:

1. Browse for Doc file and load into unbound/bound OLE control (This has been done and working)
2. Need to insert the Doc Details and Doc files into the Table (I would like to embed and not link)

What I know but can't figure out

Incase a Bound OLE control is used, I need to set ControlSource to the Table's Doc Field (which is not on the same database) - How would this be done

When I initiate the acOLECreateEmbed action, it will create the record or not?

How do I also insert the Doc Discrition details simultaneously.

Trying and trying...SOS Pls assist




Hi All,

i am designing a database for my company. They enter all the details and also they will require to attach a word doc which needs to be looked whenever necessary. for example they should be able to enter all details like acct no, refe no and along with this the doc associated with the item. What i want is end - user should be able to input a word doc (which already exists) and if he does a search based on the refnumber given for the item he should be able to get that doc and once clicked should be able to view it. Is it possible. i have tried with ole objects but since i am very new i did not know how to insert the object into the table using code or retrieve it .




Hello,
Quick overview so you understand: I have two databases, one which contains form(s) that allow users to enter in legal type cases. It has a subform in which has four fields to insert OLE objects. This form draws its data from a linked table in a database called Attachments. Not all cases have 'attachments' & the attachments are associated to cases by case number.
Anyway, my delima is - I am trying to make a less 'clunky' way for the end-user to insert objects to the cases. Currently, they can click on a button that will open the Insert Object box. It isn't that complex for a developer to use, but the regular end user, it is quite complex. Also, once an object has been inserted, it renames it. (FYI: These objects are being imported & not linked) When inserting the object, you can decide you want it to be an icon shown in the OLE field & thus you can name it there. But the problem is, if you double-click to open the document it gives it a new name that is associated with the form name. It does not retain the original file name. Does anyone know of a way for it to retain the original file name??

That is my 'biggest' problem here since these files maybe updated & even emailed - Being that they are legal documents, it would be good that they retain the name. I have just begun to use OLE objects fields so I am very, very new to this. So...I would appreciate any assistance/ideas from you guys!

Thanks in advance,
---roystreet




Hi

I've a database of audit jobs.

I'm using the code below to create a Word doc from a template and insert text and various bookmarks based on field values in an open form ("frm Recs Tracked Jobs").

Everything works well, but there is additional info in a subform ("Objectives subform") in the open form which I want to include in the Word doc also. The subform shows the objectives for each job which vary in number. I was wanting to insert the objectives at a bookmark in the Word doc above, but am unsure how to go about it. I tried creating a report and refering to that in the code, but it only inserted the first objective.

Any help would be greatly appreciated.

AL



	Code:
	
sub createdoc()

dim drname as string

drname = Forms![frm recs tracked jobs]![docfolder] & "" & Forms![frm recs tracked jobs]![Job] & " Draft Report.doc"

Set objword = New Word.Application

    With objword
      .Visible = True
      .Documents.Add Template:=("i:ia manualtemplatesdraft report.dot")
      .ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
      .ActiveWindow.ActivePane.View.NextHeaderFooter
      .Selection.TypeText Text:=("DRAFT INTERNAL AUDIT REPORT - " & Forms![frm recs tracked jobs]![Job])
      .ActiveWindow.ActivePane.View.NextHeaderFooter
      .Selection.TypeText Text:=("DRAFT INTERNAL AUDIT REPORT - " & Forms![frm recs tracked jobs]![Job])
      .Selection.Goto Name:=("Audit1")
      .Selection.TypeText Text:=(Forms![frm recs tracked jobs]![Job])
      .Selection.Goto Name:=("Audit2")
      .Selection.TypeText Text:=(Forms![frm recs tracked jobs]![Job])
      .Selection.Goto Name:=("Audit4")
      .Selection.TypeText Text:=(Forms![frm recs tracked jobs]![Job])
      .Selection.Goto Name:=("department")
      .Selection.TypeText Text:=(Forms![frm recs tracked jobs]![DepartmentName])
      .Selection.Goto Name:=("assurancelevel")
      .Selection.TypeText Text:=(Forms![frm recs tracked jobs]![Assurance DR])
      .ActiveDocument.SaveAs (drname)
      .Quit
    End With

End Sub





Does anyone have any code that will open a Word doc embedded (not linked) in an Access OLE field.

I have about a dozen pre prepared Word letters that I want embedded so the DB is not reliant on the letters being stored in a folder as Word docs.

I have been unable to find anyhting that will open them. I figure if I have the code that will open from the Access OLE field then I can add the rest to insert into bookmarks etc or have them transfer to a folder and pick it up from there.

Office 2003 and both XP and Vista




Currently I have a lot of letters that are opened from Access, data put into bookmarks, printed and the letter copied back to a memo field in a Many table. Naturally this all depends on the Word.docs being in a folder.

Is there any way that the Word docs could be stored in Access, such as an OLE field and the same thing be done.

In other words could my data base do what it does without depending on the word.docs being stored in a folder.

Edited to add


Dim WordObj As Word.Application
Dim WordDoc As Word.Document
Dim WordRange As Word.Range
Set WordObj = CreateObject("Word.Application")
Set WordDoc = WordObj.Documents.Open _
("C:LettersAMPMike.doc")
WordObj.Visible = True

Is there some way I can replace this part

("C:LettersAMPMike.doc")
WordObj.Visible = True

if the letter is embedded in OLE (or whatever) and then the rest of the code follows.




When I insert an OLE unbound Object Frame from an existing Word Document, the result is reduced in size. The Word file margins have a width of 7.5+ inches yet the OLE Object is about 5.8". The fonts in Word also have been reduced. Although it thinks it is Arial 10 - I would need to adjust to Arial 12 or 14 to get a comparable size.
This happened with some existing reports at a client's site (when client went to Office 2007, but I could always work on my computer.
I have Windows 7, Office XP-through 2010 and cannot get either an embedded OLE or copy and paste Word Document to correctly appear inside an Access Report.
Any help would be appreciated




I am in the process of creating a form which will allow the users to insert a Word document into an OLE field. I could have the users perform the following instructions:
1. Right-clickon the OLE field to bring up the menu with the Insert Object option.
2. Click on Insert Object to open up the Insert Object Window.
3. Select "Create From File"
4. Click "Browse"
5. Select the file you wish to insert.

For the sake of simplicity, I would prefer for the users to simply click a command button and have a macro (or VB module) take the user to the "Browse" window, allowing them to simply select the file.

Unfortunately, I cannot get my macro to go very far. I have tired the following sequence: 1. GoToControl 2. InsertFile but I receive a message that the action "InsertFile" is not available. Although I am in the process of teaching myself VB, this went beyond my current skill level. Can someone point me in the right direction to get this sequence to work? As always, your insights have proven to be an invaluable resource. Thanks.




Hi,

I have a small Word doc (43kb) embedded(?) (not linked) as a record in an OLE field. I have a button on a form (record source = table containing Word doc), when clicked I want to open the Word doc.

Question 1:
What is the button's "on click" vba code to open this word doc?

Question 2:
I'd like to jump to a predefined bookmark in this Word doc. Can vba code do this?

Thank you for your help.




Hello! I have a table in access 2010 with an embedded field containing word documents. I am now trying to get the document with VBA, but fails to convert the documentet back to a word object. I think the document is saved as a byte array? Does anyone know how to get the document and put it in a object variable?

Thanks in advance.




I am trying to find a way of inserting a word document into a bound OLE field on a form by using code and not having to go to the menu and using the Insert Object Open Dialog Box.
Can anyone help?




I wrote a script in cold fusion that attaches a word document as an OLE object in an access database.

Seemed like a great idea at the time (warning of things to come)

Now I need to do a word merge of all the documents that have been attached to my database. I can't simply merge because it is an OLE field type.

Can anyone tell me how to merge word documents contained in an OLE field into a regular word merge?

The reason I used OLE instead of MEMO is this: The web site was used for a scientific abstract submission process at a cancer research center. The students use many special characters and greek letters which I have found are lost when attempting to send data over a CF form using HTML.


Help help help. Thank you in advance (the cure for cancer can literally be found with your help) 8>

any comments/suggestions are greatly appreciated.




Its it possible to insert a water mark into an existing Word doc. using vb? Would anyone be able to supply example code?

Thx in advance
Mike




Hai,

I want to create new unbound Word doc's based on some embedded doc's in my database.(Access adp project sql server).

What i did in VBA so far is
-open/activate the ole-container (==> Word)
-save a copy of the opend ole-document to a temp dir with a temp name.
-Close the ole-container
-Open the temp doc

But I don't want to use diskspace and i don't want my doc to have a name already.

Please Help!!

William




I have a table where one of the fields is a OLE-object(word doc). Can I now by VBA code put the name of the document to that field.




Hello there,
This is my first post. Wonder if anyone has encountered a similar error, and although I think I know the answer.
Using Access 2010 and Word 2010 Starter Edition.
I'm by no means a professional, but I do enjoy working with VBA.
What I have is an access database where I have created several input forms. After entering all pertanent data, I have created a button to create a word doc, designing it for my daughter's business interviews and made it look like her required forms need to look. After it creates the word doc, she would be able to go in and edit anything she likes, print it, etc. But it doesn't get that far...my problem is that upon compiling my VBA code, it gives the error

Compile error
User-defined type not defined

and it errors on the statement

Dim wrdApp As Word.Application

I have Access 2010 and Word 2007 on my pc, and it creates the word doc just fine, but my daughter has the same except she has Word 2010 Starter Edition. I figured the problem lies with the starter edition of word because in her object references there is no MS Word Object Library on her pc. It's looking for msword.olb.

Is there a workaround for this anyone know, or does she just have to get a non-starter edition of Word ? She bought Access 2010 thinking that was all she needed , but now this problem.

Any help would be greatly appreciated.
Thanks
Dave




I have data in a field in a table that has CHR13 and 10 hidden characters so that the multiple lines of text will be formatted correctly.
this field is part of a query that is inserted in a Word document that I am creating from within the Access app using VBA.
When the field from the query appears on the Word doc it is recognizing the CHR13 and 10 characters and doing a CRLF, carriage return line feed
so the integrity of the text from that field is being lost and wrapping around text in the doc that I don't want.
How would I (in VBA) keep the formatted field intact when appearing in the Word doc.

Thanks. jonGG




Not sure if this is possible but I guess this is the place to find out.
In a table I have field defined as an Ole Object. When I right click on this field I get the option to Insert Object and then creat from file and I can browse and then select a bmp to store in this field, is there anyway to do this using VB?




Hi, I have a tech background from pre PC days but no knowledge of Acess/VBA etc.
I've blundered arround an created an Access DB that in addition to storing data in tables should generate a word document from a template and then attach it to an automatically generated and sent email. I've sort of got it working using code from this BBS (can't remember who but thanks guys) and the MS site.

(My code is at end of msg)

1. I can't get it to automatically do a "save as" and close the document see comments in red - what am I doing wrong?

2. This sub(?) seems to be fired off as a separate independent process, the calling procedure then calls a sub(?) to email the word doc - is there any way, other than a message box, to pause the calling proc(?) until the word doc has been closed otherwise the document for attaching to the email will not exist in time.

3. Is there a VBA instruction to bring the Word window on top when this code is called?

4. As I said I'm a newbie blundering about - feel free to criticise my(mostlly copied code) suggest improvements!!!!

5. Sorry one more - How/where do I set up global constants eg to hold file pathfor this DB - I have searched around but can't find anything about this.

Any help greatly appreciated.


	Code:
	Sub genWordDoc()

' Create a Word document from template.
   Dim WordApp As Word.Application
   Dim wrdDoc As Word.Document

   Dim strPathFilePrefix As String, strFileSuffix As String, strFullFilePath As String    
  
   ' specify path and part of filename common to both template and output file 
   strPathFilePrefix = "C:pathProblem Report "
   strFileSuffix = "xx.dot"
   ' Specify location of template
   strFullFilePath = strPathFilePrefix & strFileSuffix

   On Error Resume Next

   Set WordApp = GetObject(, "Word.Application")
   If Err.Number  0 Then
      Set WordApp = CreateObject("Word.Application")
   End If
   On Error GoTo ErrHandler  
   
   WordApp.Visible = True
   WordApp.WindowState = wdWindowStateMaximize
   Set wrdDoc = WordApp.Documents.Add(Template:=strFullFilePath, NewTemplate:=False)


   ' Replace each bookmark with field contents.
   With WordApp.Selection
   
     .GoTo what:=wdGoToBookmark, Name:="DateTested"
     .TypeText Nz([Date Tested], "")

     '   
     ' more statements to insert data here
     '
     '   
     ' Finish by putting the cursor to the top of the template letter  may not  
     ' need this if autosave etc 
     .GoTo what:=wdGoToBookmark, Name:="DateTested"
     .TypeText " "
    
   End With
    
    ' set strFullFilePath string to hold appropriate Problem Report name eg "sharepathProblemReport 123.doc"
   strFullFilePath = strPathFilePrefix & [PReportNo] & ".doc"
   
 '  among many options I've tried - dont work but no error generated  
   wrdDoc.SaveAs FileName:=strFullFilePath, FileFormat:=wdFormatDocument
   '   wrdDoc.SaveAs FileName:=strFullFilePath

'   May want to allow user to paste into doc at some stage but doc needs 
'   to already be correctly named by saveas above
'   MsgBox "Paste in any screen prints etc, and click disk icon to save document"
'  or possibly msgbox yes no qns to prompt insert and quit?

'  Does not close Word window!
   wrdDoc.Close (True)

   
' can't remember why I've stuck this here !   WordApp.Activate
   
   WordApp.Quit
    
   Set WordApp = Nothing

ErrHandler:
   Set WordApp = Nothing
      
 
End Sub