SteveGregory
Structural
- Jul 18, 2006
- 554
I have 2 Excel workbooks and I am using Excel 2013. Can someone take a look a see what I am doing wrong. Thanks!
Private Sub CommandButton1_Click()
Dim Datafile, File, Folder As String
Dim RetVal, FirstRow As Integer
Datafile = "Ram Elements Data.xls"
File = "Ram Elements Bentley Launch-NO.xls"
Folder = ThisWorkbook.Worksheets("Launch").Range("A14").Value
'Application.DisplayAlerts = False
Workbooks.Open Filename:=Folder & "\" & Datafile
'Dim DLoop As Integer
FirstRow = Workbooks(Datafile).Worksheets("Data").Range("D1").Value
Workbooks(Datafile).Worksheets("Data").Cells(FirstRow, 1).Value = Now() & " " & Environ("username")
'Display 4 rows of "Data" on "Launch" sheet, rows 5-8
Workbooks(Datafile).Worksheets("Data").Range(Cells(FirstRow - 3, 1), Cells(FirstRow, 2)).Copy _
Destination:=ThisWorkbook.Worksheets("Launch").Range("A5")
'For DLoop = 1 To 4
'Worksheets("Launch").Cells(DLoop + 4, 1).Value = Worksheets("Data").Cells(FirstRow - 4 + DLoop, 1).Value
'Worksheets("Launch").Cells(DLoop + 4, 2).Value = Worksheets("Data").Cells(FirstRow - 4 + DLoop, 2).Value
'Next DLoop
Workbooks(Datafile).Close SaveChanges:=True
ThisWorkbook.Save
Dim FileNumber, fName As String
Kill Folder & "\Ram Elements EXIT.txt"
fName = Folder & "\Ram Elements IN USE.txt"
FileNumber = FreeFile ' Get unused file number.
Open fName For Output As #FileNumber ' Open file
Write #FileNumber, Now() & " " & Environ("username")
Close #FileNumber ' Close file.
' Program is now being used and file IN USE is written
' Run Ram Elements program
'RetVal = Shell("C:\RamElem.cmd", 1)
' Run Dummy Test program
RetVal = Shell("C:\Program Files (x86)\FreeAlarmClock\FreeAlarmClock.exe", 1)
End Sub
Private Sub CommandButton1_Click()
Dim Datafile, File, Folder As String
Dim RetVal, FirstRow As Integer
Datafile = "Ram Elements Data.xls"
File = "Ram Elements Bentley Launch-NO.xls"
Folder = ThisWorkbook.Worksheets("Launch").Range("A14").Value
'Application.DisplayAlerts = False
Workbooks.Open Filename:=Folder & "\" & Datafile
'Dim DLoop As Integer
FirstRow = Workbooks(Datafile).Worksheets("Data").Range("D1").Value
Workbooks(Datafile).Worksheets("Data").Cells(FirstRow, 1).Value = Now() & " " & Environ("username")
'Display 4 rows of "Data" on "Launch" sheet, rows 5-8
Workbooks(Datafile).Worksheets("Data").Range(Cells(FirstRow - 3, 1), Cells(FirstRow, 2)).Copy _
Destination:=ThisWorkbook.Worksheets("Launch").Range("A5")
'For DLoop = 1 To 4
'Worksheets("Launch").Cells(DLoop + 4, 1).Value = Worksheets("Data").Cells(FirstRow - 4 + DLoop, 1).Value
'Worksheets("Launch").Cells(DLoop + 4, 2).Value = Worksheets("Data").Cells(FirstRow - 4 + DLoop, 2).Value
'Next DLoop
Workbooks(Datafile).Close SaveChanges:=True
ThisWorkbook.Save
Dim FileNumber, fName As String
Kill Folder & "\Ram Elements EXIT.txt"
fName = Folder & "\Ram Elements IN USE.txt"
FileNumber = FreeFile ' Get unused file number.
Open fName For Output As #FileNumber ' Open file
Write #FileNumber, Now() & " " & Environ("username")
Close #FileNumber ' Close file.
' Program is now being used and file IN USE is written
' Run Ram Elements program
'RetVal = Shell("C:\RamElem.cmd", 1)
' Run Dummy Test program
RetVal = Shell("C:\Program Files (x86)\FreeAlarmClock\FreeAlarmClock.exe", 1)
End Sub