Wednesday, December 9, 2009

Overriding Credit Limit Password

Guys,

I found an interesting post in the newsgroup, the user wanted to override the credit limit password for predefined customers or classes using VBA, code below will run temporary runtime created macro to fill the password as required and proceed:

Private Sub ExtendedPrice_AfterLostFocus()

‘Fill you if condition here.
Set CompilerApp = CreateObject("Dynamics.Application")
Commands = ""
Commands = Commands & "local integer l_file_id; " & vbCrLf
Commands = Commands & "local string pathname; " & vbCrLf
Commands = Commands & "pathname = ""C:\CreditLimitPassword.mac""; " & vbCrLf
Commands = Commands & "l_file_id = TextFile_Open(pathname, 0, 0); " & vbCrLf

Commands = Commands & "TextFile_WriteLine(l_file_id, ""  Logging file 'macro.log' ""); " & vbCrLf

Commands = Commands & "TextFile_WriteLine(l_file_id, ""  NewActiveWin dictionary 'default' form DiaLog window DiaLog  ""); " & vbCrLf
Commands = Commands & "TextFile_WriteLine(l_file_id, ""  TypeTo field ANSWER , 'ACCESS' ""); " & vbCrLf
Commands = Commands & "TextFile_WriteLine(l_file_id, ""  MoveTo field OK  ""); " & vbCrLf
Commands = Commands & "TextFile_WriteLine(l_file_id, ""  ClickHit field OK   ""); " & 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
End Sub

Hope that this helps.

Regards,
--
Mohammad R. Daoud
MVP, MCP, MCT, MCBMSP, MCTS, MCBMSS
CTO
+962 - 79 - 999 65 85
Dynamics Innovations
daoudm@dynamicsinnovations.com
http://www.dynamicsinnovations.com

No comments:

Related Posts:

Related Posts with Thumbnails