Please help!Problem description: I write GP macros from excel but cannot run that macro from Excel,but it runs flawlessly from within GP via the Bill of Materials Entry screen ==> Tools menu ==> Macro ==> Play… .I get an error saying Window not active (Line #4) when I run this macro from excel. (This VBA code runs other GP macros from excel with no issue)
GP macro and Excel VBA code shown below (ADD_ONE_ITEM.mac) with line 4 high lighted:
# DEXVERSION=14.00.0085.000 2 2NewActiveWin dictionary 'Manufacturing' form 'Graphical_BOM_Edit' window'Graphical_BOM'# CommandExec form BuiLtin command cmdEditPasteTypeTo field CPN , '61005'MoveTo field '(L) l_Quantity'MoveTo field '(L) l_Quantity'TypeTo field '(L) l_Quantity' , '1'MoveTo field 'U Of M'MoveTo field 'Add Button'ClickHit field 'Add Button'#ActivateWindow dictionary 'default' form sheLL window shell
Sub runGPmacro(gpmacrofullpath As String) 'URL REFERENCE
'p.447 of "FUNCTLIB.pdf" 'vba reference: Microsoft Dynamics GP 16.0 Object Library ' GP will not expose VBA unless it was ran as administrator ' Excel will not communicate with another application unless it is running at the same elevations ' GP and Excel must be run as administrator Dim CompilerApp As Object Dim CompilerMessage As String Dim CompilerError As Integer Dim Commands As String Set CompilerApp = GetObject("", "Dynamics.Application") Commands = "" Commands = Commands & "local string pathname; " & vbCrLf Commands = Commands & "pathname = """ & gpmacrofullpath & """" & ";" & vbCrLf Commands = Commands & "run macro pathname; " & vbCrLf CompilerError = CompilerApp.ExecuteSanscript(Commands, CompilerMessage) If CompilerError <> 0 Then MsgBox CompilerMessage End IfEnd Sub
TypeTo field 'Manufacture Order' , 'MO00046855'
MoveTo field '(L) build_pick_list'
ClickHit field '(L) build_pick_list'
TypeTo field 'Manufacture Order' , 'MO00046855'MoveTo field '(L) build_pick_list' ClickHit field '(L) build_pick_list'
If you've found this thread useful, dive deeper into User Group community content by role