Solved

code scraps after upgrade from Excel 2003 to 2013

Posted on 2014-09-17
7
153 Views
Last Modified: 2014-09-18
This code has worked perfectly on Excel 2003
----------------
Dim vtSecurities As Variant, vtFields As Variant

With Application.WorksheetFunction
    vtSecurities = .Transpose(Range("A2", Range("A2").End(xlDown)))

    vtFields = .Transpose(.Transpose("B1"))
End With


myCRTObject.AutoRelease = False

'make request
Dim sec As Long
For sec = LBound(vtSecurities) To UBound(vtSecurities)
    myCRTObject.Subscribe vtSecurities(sec), sec, vtFields
Next sec

but now running on Excel 2013 I get the runtime-error 2147417848 as I imagine on the second part. Any idea how to fix?
thx
Kongta
0
Comment
Question by:Kongta
  • 4
  • 2
7 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 40328341
Where do you actually get the error?

What is myCRTObject?
0
 

Author Comment

by:Kongta
ID: 40328390
myCRTObject is a library from a external Provider

I have deactivated all lines and unblocked line by line and got the error when cleared

For sec = LBound(vtSecurities) To UBound(vtSecurities)
     myCRTObject.Subscribe vtSecurities(sec), sec, vtFields
 Next sec

It runs properly when I execute on Excel 2003, executing on Excel 2013 gives the error. I have then designed a all new sheet in 2013 and typed all again as some (found on google) experienced a fix when they not copy/paste the code. But still a Problem. I have one read who fixed it by changing something on his range/workbook, but I dont get it.
0
 

Author Comment

by:Kongta
ID: 40328486
to be precise, the code is in a userform
Private Sub Userform_Activate()

If I read all the Problems regarding this issue, it seems to be something with the Range-Instruction, but I am a Rookie on Excel

...
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 20

Expert Comment

by:ltlbearand3
ID: 40329466
My guess is that the problem is with the myCRTObject from your external provider.  You will need to check with them to get an updated version.  You can verify this one of two ways.  The first, and simplest would be to Breakpoints from the debugger.  To do this just click on the line "With Application.WorksheetFunction" and press F9.  This will place a break point on that line.  Now do the steps to trigger this code.  The debugger will stop the code at that line.  You can press F8 to move to the next line.  Keep moving to the next line until you receive the error.  If the error happens when you move to the MyCRTObject line, then that is your problem.

The other option is to use line numbers and some error handling code.  You can modify your code as follows to accomplish that task.  The error message will give you the line number of the error:

On Error GoTo ErrHandler:
    
10    Dim vtSecurities As Variant, vtFields As Variant
    
20    With Application.WorksheetFunction
30        vtSecurities = .Transpose(Range("A2", Range("A2").End(xlDown)))
    
40        vtFields = .Transpose(.Transpose("B1"))
50    End With
    
    
60    myCRTObject.AutoRelease = False
    
    'make request
    Dim sec As Long
70    For sec = LBound(vtSecurities) To UBound(vtSecurities)
80        myCRTObject.Subscribe vtSecurities(sec), sec, vtFields
90    Next sec
        
    Exit Sub
    
ErrHandler:
    MsgBox "Error on Line " & Erl & vbCrLf & "Error Number: " & Err.Number & vbCrLf & Err.Description, vbCritical, "VBA CODE ERROR"

Open in new window

0
 

Author Comment

by:Kongta
ID: 40329880
done, when I jump to the line 'next sec' I get the error?! does this mean the error comes from the MyCRTObject line because I'm leaving this line and then the error comes or is it the 'next sec'?
0
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 500 total points
ID: 40330332
Yes, if the line "myCRTObject.Subscribe vtSecurities(sec), sec, vtFields" is highlight then you press F8 and then you get the error message, the problem is with the myCRTObject.
0
 

Author Comment

by:Kongta
ID: 40330637
ok, then I'll Close the Q as this is an external Problem. thx anyway, rgds, Kongta
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now