'#Reference {420B2830-E718-11CF-893D-00A0C9054228}#1.0#0#C:\WINDOWS\System32\scrrun.dll#Microsoft Scripting Runtime ' ' SaveAndSend.bas ' ' Author: Kyle Kershaw ' Organization: Engineering Geometry Systems ' Date: 11/05/02 ' Copyright (c) 2002, Engineering Geometry Systems ' ' General Description ' ' Save NC code, open hyperterminal, send text file. ' ' Will also create a new Comm toolbar and populate it with a SaveAndSend button ' Public Sub SaveAndSend Dim doc As FMDocument Set doc = ActiveDocument If doc Is Nothing Then MsgBox "No active document. Need an active document." Else On Error Resume Next If Not doc.ToolpathsAreValid Then ' test if toolpaths have been generated MsgBox "No Toolpaths" + vbCrLf + "Must generate toolpaths first"+ vbCrLf + "Exiting Save and Send",vbInformation,"Save and Send" Exit Sub End If Dim file_name As String, save_dir_path As String, settings As tagFMSaveNCFileType doc.GetSaveNCData(, file_name, save_dir_path,,settings) ' get SaveNC options ChDir save_dir_path ' change to folder where nc code is saved doc.SaveNC( file_name, save_dir_path,,settings) ' save the file(s) according to SaveNC options End If Dim fso As New Scripting.FileSystemObject, hyperpath As String, fcampath As String, htpath As String, not_found As Boolean hyperpathNT ="C:\Program Files\Windows NT\hypertrm.exe" hyperpath98 ="C:\Program Files\Accessories\hypertrm.exe" If Not fso.FileExists(hyperpathNT) Then ' test if hyperterminal exisits in expected folders not_found = True Else hyperpath = hyperpathNT End If If not_found = True Then If Not fso.FileExists(hyperpath98) Then MsgBox "Expected Hyperterminal in the following path(s) " + vbCrLf + hyperpathNT & " Or" + vbCrLf + hyperpath98 + vbCrLf + "Is HyperTerminal installed? Exit Sub Else hyperpath = hyperpath98 End If End If fcampath = fso.GetParentFolderName(fso.GetParentFolderName(Application.FullName)) ' get path to featurecam folder htpath = fcampath & "\Program\RS-232.ht" ' create path to .ht file If Not fso.FileExists(htpath) Then ' test if rs-232.ht file exisits in expected folder MsgBox "Expected Hyperterminal .ht file in the following path and name" + vbCrLf + htpath + vbCrLf + " Please copy .ht file to this folder" Exit Sub End If X = Shell(hyperpath & " " & htpath ,vbNormalFocus) ' run hyperterminal SendKeys "%T" ' bring up transfer menu SendKeys "T" ' bring up send text SendKeys file_name ' paste in file name Wait 2 ' pause SendKeys "~" ' enter Wait 5 ' pause MsgBox " Save and Send complete ",vbInformation, "Save and Send" End Sub ' ' create Comm toolbar and SaveAndSend button when add-in is selected. ' Private Sub AddIn_OnConnect(ByVal flags As FeatureCAM.tagFMAddInFlags) Dim bars As FMCmdBars, bar As FMCmdBar, ctrl As FMCmdBarBtn, button As FMCmdBarCtrl Set bars = Application.CommandBars Set bar = bars("Comm") If bar Is Nothing Then Set bar = bars.Add ("Comm") End If Set button = bar.Controls("SaveAndSend") If button Is Nothing Then Set ctrl = bar.Controls.Add( ,,"SaveAndSend") ctrl.FaceId = 41 bar.Visible=True End If End Sub