By David Musgrave
If you wish to automatically close Dynamics GP from .Net Application or VBA, just follow steps below:
In your Project, go to references and add a reference to “Dynamics Continuum Integration Library” then use the code below:
Dim CompilerApp As New Dynamics.Application
Dim CompilerMessage As String
Dim CompilerError As Integer
Dim Commands As String
Commands = ""
Commands = Commands & "local integer l_file_id; " & vbCrLf
Commands = Commands & "local string pathname; " & vbCrLf
Commands = Commands & "pathname = Path_GetForApp(1) + ""TEMP.MAC""; " &
vbCrLf
Commands = Commands & "l_file_id = TextFile_Open(pathname, 0, 0); " &
vbCrLf
Commands = Commands & "TextFile_WriteLine(l_file_id, ""CommandExec form
BuiLtin command cmdQuitApplication; " & vbCrLf
Commands = Commands & "TextFile_Close(l_file_id); " & vbCrLf
Commands = Commands & "if File_Probe(pathname) then " & vbCrLf
Commands = Commands & " run macro pathname; " & vbCrLf
Commands = Commands & "end if; " & vbCrLf
' Execute SanScript
CompilerError = CompilerApp.ExecuteSanscript(Commands, CompilerMessage)
If CompilerError <> 0 Then
MsgBox CompilerMessage
End If
Regards,
--
Mohammad R. Daoud
MCP, MCBMSP, MCTS, MCBMSS
Software Development Manager
+962 - 79 - 999 65 85
Dynamics Innovations
daoudm@dynamicsinnovations.com
http://www.dynamicsinnovations.com/
2 comments:
This is a similar technique to the code posted in the following example:
http://blogs.msdn.com/developingfordynamicsgp/archive/2008/09/10/running-a-macro-to-automatically-close-gp-example.aspx
David
http://blogs.msdn.com/DevelopingForDynamicsGP/
Sorry David, forgot to add your name :)
Post a Comment