Home
SEARCH

 

Launching and Terminating the WinWedge from Access


  Launching WinWedge

 


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

Back to Code Samples