Hi Andrei,
I battle for some time now with Error 5029
I have a UDF which is in the Excel sheet calculation tree
Call AddinModule.CurrentInstance.DoSendMess(SMSTR)
SMSTR is a string containing the caller (cell) address and the calculation Sub to be used
Public Sub DoSendMess(WorkName As String)
'Invoke and send Message
sc.Add(WorkName)
Me.SendMessage(MyMessage2)
End Sub
On the OnSendMessage Event the string (WorkName) in the string collection is the split into Program Name and Caller Address adn te appropriate Sub called for execution:
Private Sub AddinModule_OnSendMessage(sender As Object, e As ADXSendMessageEventArgs) Handles MyBase.OnSendMessage
If (e.Message = MyMessage2) Then
SyncLock sc.SyncRoot
Recalc = Recalc + 1
WorkName = sc.Item(0)
strx = WorkName.Split("@")
Dim OSAddres As String() = strx(1).Split("!")
ProName = strx(0)
PR = ExcelApp.Range(strx(1))
sc.RemoveAt(0)
Select Case ProName
Case "FUEL01"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcFuel01(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "FUEL02"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcFuel02(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "FUEL03"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcFuel03(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "FUEL04"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcFuel04(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "FUEL05"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcFuel05(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "FUEL06"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcFuel06(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "FUELMX"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcFuelMX(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "COMB01", "COMB02", "COMB03"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcComb(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "HEXX01", "HEXX02", "HEXX03"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcHex(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "GDES01"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcGasDesign(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "GASS01", "GASS02", "GASS03", "GARE01"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcGasSplit(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "GASM01"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcGasMix(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "STEM01", "STEM02", "STEM03", "STEM04", "STEM08", "STEM05", "STEM06", "STEM07"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcBoiler(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "EMIS01"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcEMI(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "HUMI01"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcHUMI(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case "KXAX01", "KXAX02"
If SRE = True Then Call serv.LogWrite("Start Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address, True)
Call CalcKXA(PR)
If SRE = True Then Call serv.LogWrite("Completed Calculate on Send Message, " & ProName & ", " & PR.Worksheet.Name & ", " & PR.Address)
Case Else
End Select
As you can see, I make a log entry before and after the Sub is called. Now, from time to time, I get a strange behavior as shown in the log File
21.08.06 , 10:32:52.6683 , Start Calculate on Send Message, KXAX01, Simple GT Exit T, $AC$42
21.08.06 , 10:32:52.6754 , Completed Calculate on Send Message, KXAX01, Simple GT Exit T, $AC$42
21.08.06 , 10:32:52.6764 , Start Calculate on Send Message, HEXX02, Simple GT Exit T, $AK$4
21.08.06 , 10:32:52.6973 , Start Calculate on Send Message, KXAX01, Simple GT Exit T, $AG$42
21.08.06 , 10:32:52.71 , Error in DLL _ , , Program _ , CalcKXA , Error number _ , 50290 , Exception from HRESULT: 0x800AC472 , Line 170
21.08.06 , 10:32:52.73 , Error in DLL _ , , Program _ , CalcKXA , Error number _ , 50290 , Exception from HRESULT: 0x800AC472 , Line 170
21.08.06 , 10:32:52.76 , Error in DLL _ , , Program _ , CalcKXA , Error number _ , 50290 , Exception from HRESULT: 0x800AC472 , Line 3180
21.08.06 , 10:32:52.78 , Error in DLL _ , , Program _ , CalcKXA , Error number _ , 50290 , Exception from HRESULT: 0x800AC472 , Line 3540
21.08.06 , 10:32:52.80 , Error in DLL _ , , Program _ , CalcKXA , Error number _ , 50290 , Exception from HRESULT: 0x800AC472 , Line 5400
21.08.06 , 10:32:52.8018 , Completed Calculate on Send Message, KXAX01, Simple GT Exit T, $AG$42
21.08.06 , 10:32:52.8018 , Start Calculate on Send Message, HEXX02, Simple GT Exit T, $AS$4
21.08.06 , 10:32:52.82 , Error in DLL _ , , Program _ , CalcHex , Error number _ , 50290 , Exception from HRESULT: 0x800AC472 , Line 720
21.08.06 , 10:32:52.84 , Error in DLL _ , , Program _ , OnSendMessage , Error number _ , 50290 , Exception from HRESULT: 0x800AC472 , Line 555
21.08.06 , 10:32:52.8491 , Completed Calculate on Send Message, HEXX02, Simple GT Exit T, $AK$4
Calculation for cell $AG$42 is started before calculation for cell $AK$4 is completed
In summary it looks like
$AK$4 is started
$AG$42 is started
5 Errors 50290 (which I believe is when different Subs want to write to the sheet at the same time)
$AG$42 is completed
$AS$4 is started
2 Errors 50290
$AK$4 is completed
It looks to me that OnSendMessage is Running again before it has finished the previous run? But how is that possible?
I read your post about volatile UDF's, could it be that my UDF is changed to volataile, but then the OnSendMessage should still process the StringCollection one be one in a row?
My UDF has many optional parameters including Range Address as string, but no "As Range" only Double and string
Public Shared Function alera(Prog As String, Optional D1 As Double = 0,
Optional D2 As Double = 0, Optional D3 As Double = 0,
Optional D4 As Double = 0, Optional D5 As Double = 0, Optional D6 As Double = 0,
Optional D7 As Double = 0, Optional D8 As Double = 0, Optional D9 As Double = 0,
Optional D10 As Double = 0, Optional D11 As Double = 0, Optional D12 As Double = 0,
Optional D13 As Double = 0, Optional D14 As Double = 0, Optional D15 As Double = 0,
Optional D16 As String = "", Optional D17 As String = "", Optional D18 As String = "",
Optional D19 As String = "", Optional D20 As String = "") As String
Any Idea where this behavior could come from?
Thank you and kind regards
Michael |