H
hunter_alexander
Greetings everyone.
I posted this on another section and got refered to here. Not sure if this
is the place to post this, but here goes......
One of our old employees created an excel add in for adding the times on our
excel timesheets. This was for excel 2003. We have since upgraded to Office
2007 and now the add in hangs excel when opening any excel document. I have
tested it and if you deselect the checkbox for the add in, excel will open
fast with no problems. Check the box for the add in and excel will hang every
time.
Here is the code from the file the way it was written, and the actual file
has a .xla file extension:
'Adds the times in the Description of Services column in timesheets
Sub AddTimes()
Dim sCellText As String
Dim sTimeTotal As String
Dim iStartPosition As Integer
Dim iEndPosition As Integer
Dim dTimeTotal As Double
sCellText = ActiveCell
'Steps through the string looking for time entry delimiters
For iStartPosition = 1 To (Len(sCellText) - 1) Step 1
'Finds a time entry beginning delimiter
If Mid(sCellText, iStartPosition, 1) = "(" Then
'Steps through from the current time entry beginning delimiter
For iEndPosition = (iStartPosition + 1) To (iStartPosition + 7)
Step 1
'Finds the corresponding time entry ending delimiter
If Mid(sCellText, iEndPosition, 1) = ")" Then
'Makes sure there is a valid number inside the delimiters
If IsNumeric(Mid(sCellText, (iStartPosition + 1),
((iEndPosition - iStartPosition) - 1))) Then
'Adds this time entry to the total
dTimeTotal = dTimeTotal + CDbl(Mid(sCellText,
(iStartPosition + 1), ((iEndPosition - iStartPosition) - 1)))
End If
'Moves on to the next time entry beginning delimiter...
this one was handled already
Exit For
End If
Next iEndPosition
End If
Next iStartPosition
'Creates the message box with a decent format
If dTimeTotal > 0 Then
sTimeTotal = CStr(dTimeTotal)
'Always shows 1 decimal place, even for #.0 time entries
If Len(sTimeTotal) < 2 Then
MsgBox sTimeTotal & ".0", , "Total Time:"
Else
MsgBox sTimeTotal, , "Total Time:"
End If
Else
MsgBox "There are no valid time entries to add in the selected
cell.", , "Select a Description of Services Cell..."
End If
End Sub
Basically, we would enter time in the excel document like this....."worked
on e-mail (.7); worked on monitor (.2).
To add the time, we would press the control key and the t key at the same
time, and it would add everything between the (). Worked perfect till we
changed to office 2007. I am thinking that maybe the file extension could be
the problem, as it seems that all the 2007 office product file extensions
seem to have changed.
Any help would be greatly appreciated.
Craig
I posted this on another section and got refered to here. Not sure if this
is the place to post this, but here goes......
One of our old employees created an excel add in for adding the times on our
excel timesheets. This was for excel 2003. We have since upgraded to Office
2007 and now the add in hangs excel when opening any excel document. I have
tested it and if you deselect the checkbox for the add in, excel will open
fast with no problems. Check the box for the add in and excel will hang every
time.
Here is the code from the file the way it was written, and the actual file
has a .xla file extension:
'Adds the times in the Description of Services column in timesheets
Sub AddTimes()
Dim sCellText As String
Dim sTimeTotal As String
Dim iStartPosition As Integer
Dim iEndPosition As Integer
Dim dTimeTotal As Double
sCellText = ActiveCell
'Steps through the string looking for time entry delimiters
For iStartPosition = 1 To (Len(sCellText) - 1) Step 1
'Finds a time entry beginning delimiter
If Mid(sCellText, iStartPosition, 1) = "(" Then
'Steps through from the current time entry beginning delimiter
For iEndPosition = (iStartPosition + 1) To (iStartPosition + 7)
Step 1
'Finds the corresponding time entry ending delimiter
If Mid(sCellText, iEndPosition, 1) = ")" Then
'Makes sure there is a valid number inside the delimiters
If IsNumeric(Mid(sCellText, (iStartPosition + 1),
((iEndPosition - iStartPosition) - 1))) Then
'Adds this time entry to the total
dTimeTotal = dTimeTotal + CDbl(Mid(sCellText,
(iStartPosition + 1), ((iEndPosition - iStartPosition) - 1)))
End If
'Moves on to the next time entry beginning delimiter...
this one was handled already
Exit For
End If
Next iEndPosition
End If
Next iStartPosition
'Creates the message box with a decent format
If dTimeTotal > 0 Then
sTimeTotal = CStr(dTimeTotal)
'Always shows 1 decimal place, even for #.0 time entries
If Len(sTimeTotal) < 2 Then
MsgBox sTimeTotal & ".0", , "Total Time:"
Else
MsgBox sTimeTotal, , "Total Time:"
End If
Else
MsgBox "There are no valid time entries to add in the selected
cell.", , "Select a Description of Services Cell..."
End If
End Sub
Basically, we would enter time in the excel document like this....."worked
on e-mail (.7); worked on monitor (.2).
To add the time, we would press the control key and the t key at the same
time, and it would add everything between the (). Worked perfect till we
changed to office 2007. I am thinking that maybe the file extension could be
the problem, as it seems that all the 2007 office product file extensions
seem to have changed.
Any help would be greatly appreciated.
Craig