Sunday, December 7, 2008

Programmatically Closing for Dynamics GP

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/

Related Posts:

Related Posts with Thumbnails