0

The error occurs in here:

Application.Run "Macro2.Execute", param
...

Execute is a public sub i called from other Module "Macro2" installed in another template.

Upon run of the code:

IF there is NO open Word Document = No error

IF another instance of Word Document is open = Stated error occurs.

Is there any fix on this? :(

The whole code is below:

Dim objWord As Object

On Error Resume Next 'suppress error checking for the next instruction
 Set objWord = GetObject(, "Word.Application")

 If objWord Is Nothing Then
    'no instance, so make a new one
    Set objWord = CreateObject("Word.Application")
    bNewInstance = True
 End If
On Error GoTo 0 'resume error checking   

'Close Document1
ActiveDocument.Close wdDoNotSaveChanges

' Open the global template
Set docAddIn = objWord.Documents.Open("C:\WordAPI\GlobalTemplate.dotm")
docAddIn.ActiveWindow.Visible = False

' Run the the public sub Execute from global template module "Macro2"
Application.Run "Macro2.Execute", param
Roland
  • 39
  • 1
  • 6
  • 2
    without providing the code, there is no way we can help you... – ᴄʀᴏᴢᴇᴛ Jan 05 '17 at 08:21
  • What you are possibly missing is reference to another Template (name). Solution can look like this `Application.Run "'TemplateNameOrSomething'!Macro2.Execute, param`. You need to make some test of what to put in `TemplateNameOrSomething` on your own. – Kazimierz Jawor Jan 05 '17 at 08:34
  • Hi KazimierzJawor, hmmmm... I've tried your suggestion before but it doesn't work in me. :( – Roland Jan 05 '17 at 08:54

0 Answers0