×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VBA Corrupt Code

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

RE: VBA Corrupt Code

Well, have you single stepped it to see where it fails?
What is the error message?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources