Software Support
Closing and Opening WinWedge in Access
Launching WinWedge:
Similarly as with the data collection code, you'll need a macro defined in Access designated to run the subroutine LaunchWedge(). To trigger the code to start automatically upon opening up the database, your macro must be called "Autoexec".
Sub LaunchWedge()
' This function will launch the Wedge feeding it the
' name of a configuration file on the command line
' causing the Wedge to automatically load the config
' file and activate itself
Const MyPort As String = "COM1"
Const CmdLine As String = "C:\WinWedge\WinWedge.EXE C:\WinWedge\MyConfig.SW3"
' Change "CmdLine" to specify the correct path for your copy of WinWedge.Exe
' Make sure that the complete path is specified for your configuration file as well
Dim ShellReturnVal As Long
Dim TwoSecsFromNow As Date
On Error GoTo ErrorHandler ' Set up an error trap
' try to activate the Wedge Window to see if it is already running
' if Wedge is not running, this will generate an error
AppActivate "Software Wedge - " & MyPort
' NOTE: For WinWedge 3.0 Std use the following line instead:
' AppActivate "WinWedge - " & MyPort
AppActivate "Microsoft Access" ' set focus back to Access & exit
Exit Sub ' all done!
ErrorHandler:
' If we get here the wedge is not running, so launch it:
ShellReturnVal = Shell(CmdLine)
TwoSecsFromNow = Now + TimeValue("00:00:02")
' give wedge time to load
While Now < TwoSecsFromNow ' wait for 2 seconds
DoEvents
Wend
Resume Next ' resume
End Sub
Closing WinWedge
Function KillWedge () ' This function unloads the Wedge from memory
' initiate DDE channel with wedge on COM1
chan = DDEInitiate("WinWedge", "Com1")
' send AppExit command to Wedge
DDEExecute chan, "[AppExit]"
' close the DDE Channel
DDETerminate chan
End Function
Categories: Macro / Code Sample, Microsoft Access, WinWedge
Last Updated: 2011.12.19
Need more help?Don't hesitate to call or email us with your questions! |
Technical Support: 215-496-0222Toll-Free: 1 (800) 722-6004 |