VBA Corrupt Code
VBA Corrupt Code
(OP)
the Code that worked GREAT for 4 days then WHAM Nothing but error's >>??? what up ("PULLING HAIR")
'Using DDE Animate for TAG values
Dim objExcel As Object
Dim sExcelFilePath As String
Dim ExcelWasNotRunning As Boolean
Set objExcel = GetObject(, "Excel.Application")
If Err.Number <> 0 Then ExcelWasNotRunning = True
Err.Clear ' Clear Err object in case error occurred.
sExcelFilePath = gProject.Path & "\sRecipe.xls"
Set objExcel = GetObject(sExcelFilePath)
'Calday = UserForm1.Calendar1.Today
'TAGS to Set and Read Go Here
With objExcel.Application.WorkBooks("sRecipe.xls").Worksheets("Daily")
Set tag1 = gTagDb.GetTag("RDFAST")
Set tag2 = gTagDb.GetTag("SAWTOOTH")
Set tag3 = gTagDb.GetTag("RUFAST")
Set Tag4 = gTagDb.GetTag("SAWTOOTH")
Set tag5 = gTagDb.GetTag("SINEFAST")
Set tag6 = gTagDb.GetTag("RUFAST")
Set Tag7 = gTagDb.GetTag("day")
'Set the Font
.Rows(1).Font.Bold = True
'Format the headings in Excel
Step = Tag7.Value
If Step < 1 Or Step = 31 Then Step = Step + 6 ' starting cell After end of Month and clear
Step = Step + 1
'Write the data to Excel By Step Value
.Cells(Step, 2).Value = Date
.Cells(Step, 3).Value = gTagDb.GetTag("RDFAST").Value
.Cells(Step, 4).Value = gTagDb.GetTag("SAWTOOTH").Value
.Cells(Step, 5).Value = gTagDb.GetTag("SINEFAST").Value
.Cells(Step, 6).Value = gTagDb.GetTag("RUFAST").Value
.Cells(Step, 7).Value = gTagDb.GetTag("SAWTOOTH").Value
' Print to the Windows default printer
'.PrintOut Copies:=1, Collate:=True
End With
' If this copy of Microsoft Excel was not already running when you
' started, close it using the Application property's Quit method.
If ExcelWasNotRunning = True Then
'This prevents the Save Changes dialog from displaying
objExcel.Application.DisplayAlerts = False
'No changes are saved upon quitting
objExcel.Application.Quit
End If
'JUMP TO CLOSE
GoTo Clos
bottom:
tag1.Value = 1
MESS = Err.Description
MsgBox MESS
Err.Clear
GoTo clos2
Clos:
tag1.Value = 1
clos2:
' WorkBooks.Close
Set tag1 = Nothing
Set tag2 = Nothing
Set tag3 = Nothing
Set Tag4 = Nothing
Set tag5 = Nothing
End Sub
'Using DDE Animate for TAG values
Dim objExcel As Object
Dim sExcelFilePath As String
Dim ExcelWasNotRunning As Boolean
Set objExcel = GetObject(, "Excel.Application")
If Err.Number <> 0 Then ExcelWasNotRunning = True
Err.Clear ' Clear Err object in case error occurred.
sExcelFilePath = gProject.Path & "\sRecipe.xls"
Set objExcel = GetObject(sExcelFilePath)
'Calday = UserForm1.Calendar1.Today
'TAGS to Set and Read Go Here
With objExcel.Application.WorkBooks("sRecipe.xls").Worksheets("Daily")
Set tag1 = gTagDb.GetTag("RDFAST")
Set tag2 = gTagDb.GetTag("SAWTOOTH")
Set tag3 = gTagDb.GetTag("RUFAST")
Set Tag4 = gTagDb.GetTag("SAWTOOTH")
Set tag5 = gTagDb.GetTag("SINEFAST")
Set tag6 = gTagDb.GetTag("RUFAST")
Set Tag7 = gTagDb.GetTag("day")
'Set the Font
.Rows(1).Font.Bold = True
'Format the headings in Excel
Step = Tag7.Value
If Step < 1 Or Step = 31 Then Step = Step + 6 ' starting cell After end of Month and clear
Step = Step + 1
'Write the data to Excel By Step Value
.Cells(Step, 2).Value = Date
.Cells(Step, 3).Value = gTagDb.GetTag("RDFAST").Value
.Cells(Step, 4).Value = gTagDb.GetTag("SAWTOOTH").Value
.Cells(Step, 5).Value = gTagDb.GetTag("SINEFAST").Value
.Cells(Step, 6).Value = gTagDb.GetTag("RUFAST").Value
.Cells(Step, 7).Value = gTagDb.GetTag("SAWTOOTH").Value
' Print to the Windows default printer
'.PrintOut Copies:=1, Collate:=True
End With
' If this copy of Microsoft Excel was not already running when you
' started, close it using the Application property's Quit method.
If ExcelWasNotRunning = True Then
'This prevents the Save Changes dialog from displaying
objExcel.Application.DisplayAlerts = False
'No changes are saved upon quitting
objExcel.Application.Quit
End If
'JUMP TO CLOSE
GoTo Clos
bottom:
tag1.Value = 1
MESS = Err.Description
MsgBox MESS
Err.Clear
GoTo clos2
Clos:
tag1.Value = 1
clos2:
' WorkBooks.Close
Set tag1 = Nothing
Set tag2 = Nothing
Set tag3 = Nothing
Set Tag4 = Nothing
Set tag5 = Nothing
End Sub





RE: VBA Corrupt Code
What is the error message?