OLE Word Verbs / Insert Date

tweedle

Well-known Member
Joined
Aug 1, 2010
Messages
1,559
I'm missing the concept.
So I'm inserting word doc into my excel sheet (code below).
I should like to, as in Word, Insert Date.
So far, what I've read has been rather...abstract.

Does anyone have an example of how to insert content into a Word OLE object?

Code:
Sub WordObjectMake()
With Sheets("Sheet1")
    .Activate
    .Range("1:5").Insert xlShiftDown
    
    .Cells(3, 2).Activate
Set OLEObj = .OLEObjects.Add(ClassType:="Word.Document")
End With
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try:
Code:
Sub WordObjectMake()
Application.ScreenUpdating = False
Dim xlWS As Worksheet, OLEObj As OLEObject
Set xlWS = Sheets("Sheet1")
With xlWS
  .Range("1:5").Insert xlShiftDown
   With .Cells(3, 2)
  Set OLEObj = xlWS.OLEObjects.Add(ClassType:="Word.Document", Link:=False, _
    DisplayAsIcon:=False, Left:=.Left, Top:=.Top, Width:=150, Height:=10)
  End With
  OLEObj.Activate
  With OLEObj.Object.Application.Wordbasic
    .Insert Format(Now(), "DDDD, D MMMM YYYY")
    .FileClose
  End With
  Set OLEObj = Nothing
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,627
Messages
6,120,610
Members
448,973
Latest member
ChristineC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top