Attribute VB_Name = "ExcelSave"
Option Explicit
'Const VK_MENU = 18 ' Alt key
Const VK_MENU = 11 ' Ctrl key
Const VK_SNAPSHOT = 44
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
'
' this routine saves all collected data to MS Excel
'
Public Sub Save_B4_Exit()
Dim FName As String
Dim test_str1 As String
Dim test_str2 As String
Dim test_str3 As String
Dim OUTPATHNETWORK As String
Dim OUTPATHNETWORK_BAK As String
Dim OUTPATHLOCAL As String
Dim OUTPATH As String
xlWS.Cells(1, 1).ColumnWidth = 20
xlWS.Cells(1, 1).HorizontalAlignment = xlCenter
Call Write2Excel(1, 1, "Test Location: NH" & Test_location)
test_str1 = Form1.Combo3.List(Form1.Combo3.ListIndex) & "_"
test_str2 = Form1.Text1.Text & "_"
test_str3 = "NH" & Test_location
FName = test_str1 & test_str2 & test_str3
'OUTPATH = Form1.Text5.Text & FName & ".xlsx" ' use this with MSOffice 2007/2010. Mostly for Windows 7.
'OUTPATH = "C:\" & FName & ".xlsx" ' use this with MSOffice 2007/2010
'OUTPATH = "C:\" & FName & ".xls" ' use this with MSOffice 2003
OUTPATH = "%UserProfile%\Desktop\" & FName & ".xlsx" ' Windows 7 desktop
OUTPATHNETWORK = "S:\QUALITY CONTROL LOG\Light Tube Testing\" & FName & ".xlsx" ' use this with MSOffice 2007 to network path
'OUTPATHNETWORK = "S:\" & FName & ".xlsx"
'OUTPATHNETWORK_BAK = "S:\QUALITY CONTROL LOG\Light Tube Testing\" & FName & "_bak.xlsx"
xlApp.DisplayAlerts = False
xlWB.SaveAs OUTPATH
xlWB.SaveAs OUTPATHNETWORK
If (Exit_button) Then
xlWB.Close (True)
xlApp.Quit
Set xlWS = Nothing
Set xlWB = Nothing
Set xlApp = Nothing
End If
End Sub