CreateObject(“Word.Application”) Office 97 vs. Office 2010

In LotusScript when you create a Object af Word in Office 97, you can write something like this.

Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Set wdApp = CreateObject(“Word.Application”)
Set docNew = wdApp.Documents.Add(“L:\merge.doc”)
Dim doc As NotesDocument
Dim session As New NotesSession()
Set doc = uidoc.Document
With wdApp.ActiveDocument.Bookmarks
.Item(“Nummer”).Range.Text = uidoc.FieldGetText( “number” )
.Item(“User”).Range.Text = uidoc.FieldGetText( “User” )
End With
wdApp.visible = True

This will open a Word document and put some tekst from a Notes document in it. But if you use this code with Office 2010 you will get a error.

Type Mismatch i method NRun: FROMVAR found, Unknown expected

This is because the create Object has not yet started, when this scrips run. Office 2010 is to slow. It works when you run i debug mode, but not if you run it without.

One workaround is to put a sleep statement in code.


Set wdApp = CreateObject(“Word.Application”)
Sleep(3) ‘waits 3 seconds
Set docNew = wdApp.Documents.Add(“L:\merge.doc”)

Try if you can get it down to 1 or 2. Depending on your network and CPU

Then the Word Document will open without errors

This entry was posted in Lotus, Tip and tagged , , , . Bookmark the permalink.

3 Responses to CreateObject(“Word.Application”) Office 97 vs. Office 2010

  1. team awesome says:

    I have been surfing online more than 3 hours as of late, but I by no means discovered any fascinating article like yours. It is beautiful value enough for me. In my opinion, if all webmasters and bloggers made excellent content as you did, the internet shall be a lot more helpful than ever before.

  2. 304525 908019Thanks for providing such a terrific post, it was exceptional and quite informative. It is my 1st time that I check out here. I identified a great deal of informative stuff within your post. Maintain it up. Thank you. 286908

Comments are closed.