{"id":61,"date":"2012-02-13T08:13:38","date_gmt":"2012-02-13T07:13:38","guid":{"rendered":"http:\/\/teske.dk\/?p=61"},"modified":"2012-02-18T07:42:01","modified_gmt":"2012-02-18T06:42:01","slug":"createobjectword-application-office-97-vs-office-2010","status":"publish","type":"post","link":"http:\/\/teske.dk\/?p=61","title":{"rendered":"CreateObject(&#8220;Word.Application&#8221;) Office 97 vs. Office 2010"},"content":{"rendered":"<p>In LotusScript when you create a Object af Word in Office 97, you can write something like this.<\/p>\n<p>Dim workspace As New NotesUIWorkspace<br \/>\nDim uidoc As NotesUIDocument<br \/>\nSet uidoc = workspace.CurrentDocument<br \/>\nSet wdApp = CreateObject(&#8220;Word.Application&#8221;)<br \/>\nSet docNew = wdApp.Documents.Add(&#8220;L:\\merge.doc&#8221;)<br \/>\nDim doc As NotesDocument<br \/>\nDim session As New NotesSession()<br \/>\nSet doc = uidoc.Document<br \/>\nWith wdApp.ActiveDocument.Bookmarks<br \/>\n\t.Item(&#8220;Nummer&#8221;).Range.Text = uidoc.FieldGetText( &#8220;number&#8221; )<br \/>\n\t.Item(&#8220;User&#8221;).Range.Text = uidoc.FieldGetText( &#8220;User&#8221; )<br \/>\n\t&#8230;&#8230;.<br \/>\nEnd With<br \/>\nwdApp.visible = True\t<\/p>\n<p>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.<\/p>\n<p><a href=\"http:\/\/teske.dk\/wp-content\/uploads\/2012\/02\/Captured11.jpg\"><img loading=\"lazy\" src=\"http:\/\/teske.dk\/wp-content\/uploads\/2012\/02\/Captured11-300x91.jpg\" alt=\"\" title=\"Captured11\" width=\"300\" height=\"91\" class=\"alignnone size-medium wp-image-62\" srcset=\"http:\/\/teske.dk\/wp-content\/uploads\/2012\/02\/Captured11-300x91.jpg 300w, http:\/\/teske.dk\/wp-content\/uploads\/2012\/02\/Captured11.jpg 428w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Type Mismatch i method NRun: FROMVAR found, Unknown expected<\/p>\n<p>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.<\/p>\n<p>One workaround is to put a sleep statement in code.<\/p>\n<p>Ex.<\/p>\n<p>Set wdApp = CreateObject(&#8220;Word.Application&#8221;)<br \/>\nSleep(3) &#8216;waits 3 seconds<br \/>\nSet docNew = wdApp.Documents.Add(&#8220;L:\\merge.doc&#8221;)<\/p>\n<p>Try if you can get it down to 1 or 2. Depending on your network and CPU<\/p>\n<p>Then the Word Document will open without errors<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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(&#8220;Word.Application&#8221;) Set docNew = wdApp.Documents.Add(&#8220;L:\\merge.doc&#8221;) Dim &hellip; <a href=\"http:\/\/teske.dk\/?p=61\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[74,77],"tags":[3,24,25,4],"_links":{"self":[{"href":"http:\/\/teske.dk\/index.php?rest_route=\/wp\/v2\/posts\/61"}],"collection":[{"href":"http:\/\/teske.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/teske.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/teske.dk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/teske.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=61"}],"version-history":[{"count":3,"href":"http:\/\/teske.dk\/index.php?rest_route=\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":103,"href":"http:\/\/teske.dk\/index.php?rest_route=\/wp\/v2\/posts\/61\/revisions\/103"}],"wp:attachment":[{"href":"http:\/\/teske.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/teske.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/teske.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}