0

I've been looking for threads that could help me with this error "Call was rejected by callee" but I've found nothing, so far, that could help me. I'm new to VBScript and I've been learning to create a script that could automatically transfer data from database to Excel through a button in ClearSCADA. My project is about creating a script code for a button in ClearSCADA HMI where when I press it, it can automatically export any data (like an alarms list or events list) from the scada server to Excel.

I keep getting this error "Call was rejected by callee" and it's always in this part (seen below) of my code that causes this error.

xlSheet.Cells(1, 1).Value = "Severity"
xlSheet.Cells(1, 2).Value = "Message"
xlSheet.Cells(1, 3).Value = "Time"
xlSheet.Cells(1, 4).Value = "Source"
xlSheet.Cells(1, 5).Value = "User"

Also here's a picture of the error:

error

UPDATE: It worked! I decided to put delay in between xlApp.ActiveWorkbook.SaveAs "C:\HData.xlsx" and xlSheet.Cells(1, 1).Value = "Severity". Thanks for the help!!!

somberset
  • 1
  • 1
  • 2
  • Have you tried suggestions from https://social.msdn.microsoft.com/Forums/en-US/7e4f22bd-bf34-43bc-98d2-c604ef7fd2b1/call-was-rejected-by-callee-using-vba-with-excel?forum=isvvba? – GSerg Jul 08 '18 at 10:31
  • @GSerg, yes I've already tried that and the error is still there. In fact, I tried to run it again just now and this time 'xlSheet.Cells(1, 3).Value = "Time"` is the one with "call was rejected by callee" error – somberset Jul 08 '18 at 10:36
  • If Excel busy at the time? What if you make the script sleep after `SaveAs`? – GSerg Jul 08 '18 at 10:48
  • @GSerg I've tried this `WScript.Sleep 1000` but it doesn't seem to work. I've seen various version of putting delay in vbscript but I'm confused which one is which. It says 'Variable is undefined: WScript' – somberset Jul 08 '18 at 10:50
  • @somberset That's not a day-to-day Excel error. Can you provide more information about the proejct? Are you calling this sub from an external procedure? How is [tag:scada] involved? It would also be helpful if you were to reduce your code to only the section that's causing the error (see **how to make a [mcve]**), and add that (as text, not image) to your question. – ashleedawg Jul 08 '18 at 12:43
  • @ashleedawg sorry if it didn't make sense the first time, but no, i'm calling the sub from within the clearscada itself. I'm creating an HMI in clearscada and a part of it is a button that when pressed, it exports a table from a scada dsn to excel. – somberset Jul 08 '18 at 13:12
  • Even if whitespace and comments were considered code lines in vb-script (which I don't believe they are) you are not showing 25 lines of code. –  Jul 08 '18 at 14:29
  • btw, I fear you may have a long wait if you are expecting someone to retype your code from an image in order to proof-test. So there is no [mcve] and you are showing code in an image. I'll give you a minute to correct that through an [edit]. –  Jul 08 '18 at 14:32
  • Similar: https://stackoverflow.com/questions/25687988/vbscript-excel-application-object-statusbar-call-rejected-by-callee It may be you have a timing problem and Excel is busy with something else which causes your call to fail. – Tim Williams Jul 08 '18 at 19:37

0 Answers0