Unhandled exception when code runs for the first time,but works fine the second

Hi All,
I have the following code snippet
private void RGL_Click(object sender, RibbonControlEventArgs e)
Word._Document oDoc;
           oDoc = Globals.ThisAddIn.Application.ActiveDocument;
            object start = oDoc.Content.Start;
            object end = oDoc.Content.End;
            oDoc.Range(ref start, ref end).LanguageID = WdLanguageID.wdEnglishCanadian;
            oDoc.Range(ref start, ref end).NoProofing = 0;
Microsoft.Office.Interop.Word.ReadabilityStatistic DocStats;
                DocStats = oDoc.ReadabilityStatistics[10];------>exception occurs here when code runs first time
                MessageBox.Show(DocStats.Name + " " + DocStats.Value);
When I copy paste a document and click on the button it raises a COM exception but if I click continue and click on the button again, the correct grade level score is displayed.Cant figure out why this is happening.

Thanks for the answer Eugene, this exception never shows up if I type something and click on the rgl button , but if i open a huge document that is already in Canadian english and click on this ribbon it gives me the following exception
System.Runtime.InteropServices.COMException was unhandled by user code
  HelpLink=wdmain11.chm#36966
  HResult=-2146824090
  Message=Command failed
  Source=Microsoft Word
  ErrorCode=-2146824090
  StackTrace:
       at Microsoft.Office.Interop.Word.ReadabilityStatistics.get_Item(Object& Index)
       at UsabilityMapping_V01.Ribbon1.RGL_Click(Object sender, RibbonControlEventArgs e) in <my path> 1211
       at Microsoft.Office.Tools.Ribbon.RibbonPropertyStorage.ControlActionRaise(IRibbonControl control)
       at Microsoft.Office.Tools.Ribbon.RibbonPropertyStorage.ButtonClickCallback(RibbonComponentImpl component, Object[] args)
       at Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.Invoke(RibbonComponentCallback callback, Object[] args)
       at Microsoft.Office.Tools.Ribbon.RibbonMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.System.Reflection.IReflect.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
  InnerException: 

Similar Messages

  • I bought a camera connection kit. First time it worked fine, using the USB connector, but now neither the USB or SD connector works. The iPad shows a connector is attached, but Photos doesn't open. Any ideas? thanks

    I bought a camera connection kit. First time it worked fine, using the USB connector, but now neither the USB nor SD connector works. The iPad shows a connector is attached, but Photos doesn't open. Any ideas? thanks

    If you have not done so, try exiting the Photo app (and maybe more apps if you have a lot open) from the Open Apps List and see if a discount/reconnect opens the app. If that does not work, try powering down the iPad and test. If it is still not working try a hard reset by pressing both Home and Sleep/Wake buttons at the same time until the Apple graphic appears, ignoring the Slide to Power Off button.

  • Repeat credit check does not happen for already released sales orders when CMGST =D, for the second time using FM SD_ORDER_CREDIT_CHECK

    Hi,
       I have written a routine which will call the FM SD_ORDER_CREDIT_CHECK whenever there is a rejection and again unrejection of a same sales order, we are only concerned about already credit released sales orders, the scenario is as follow
    1). Sales order created in the system --> Credit check --> Credit blocked
    2). Release credit block manually CMGST =D
    3). Reject sales order then unreject the same
    4) Routine will determine rejection and unrejection of the order while saving and will call the FM SD_ORDER_CREDIT_CHECK
    5)   The order is credit checked and blocked if necessary
    All goes well till this point
    but when the same sales order is rejeceted and unrejected multiple times either partially/ fully then the Custom routine calls the FM for credit check but the FM fails to put the order back on credit hold
    in short the FM works only for the first time incase of mutiple rejection and unrejection of teh same sales order then the FM SD_ORDER_CREDIT_CHECK fails to put the order back on credit hold from the second time onwards
    if some one any idea of the behavior of this FM please share your thoughts and inputs . thanks !!

    Issue resolved
    The Standard FM “SD_ORDER_CREDIT _CHECK” uses the field  “Release date of the document determined by credit management  VBAK – CMFRE”
    For any sales order that is manually credit released in a single day, Only one credit check is triggered (per day) if there is any change in the sales order and then the order goes back to credit hold and if again the order is manually credit released for the second time in a single day there will be no credit check  (still the order will pass into FM but  the update entry in the internal table will be blank)this is a standard functionality
    Process of rejection and unrejection :
    Blocked order -->released-->blocked again (first time after manual release same day) unrejected (same day) -->but no credit check  (all this in a single day)
    note : OVA8 - released document still unchecked = 0 Days , Deviation %= blank

  • Instance Manager Unhandled Exception when trying to view the status!

    Hi,
    I got an error while trying to view the failed instances in the Instance manager. Can any one please help how to fix this tomcat error.
    Unhandled Exception  Back  | Exit 
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:507) at java.util.ArrayList.get(ArrayList.java:324) at com.crystaldecisions.sdk.occa.infostore.internal.al.get(Unknown Source) at org.apache.jsp.instancesByStatus.main_jsp._jspService(main_jsp.java:439) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:534) 
    Thanks,
    Kalyan.

    Hi Kalyan,
    Which is the Business Objects version at your end?Are you running XI R1 or XI R2?
    Do you have any Service Packs, Critical, Monthly, or Weekly hotfixes installed?
    If you have no service packs installed, please install the latest service pack from our SAP Support Portal.
    I hope this the issue gets resolved by this.
    Regards,
    Arun Sasi

  • Dear All, I can't play flash videos from any web site through firefox because it freezes but when i run firefox as administrator then it works fine (But Google Chrome Plays all videos normally.) . I am using Windows 7 & Firefox 7.0.1. Please help

    Dear All,
    Firefox hangs when i try to play flash videos from any site but when i run firefox as administrator it works fine. (but Google Chrome, Opera & I.E9 Plays videos without running as administrator.) I am using Windows 7 & Firefox 7.0.1. Please help.

    A possible cause is security software (firewall) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    *https://support.mozilla.com/kb/Server+not+found
    *https://support.mozilla.com/kb/Firewalls

  • When I run script from terminal it is working fine but it is not working from installer

    Here is my script look like.
    #! /bin/sh
    defaults write com.apple.LaunchServices LSHandlers -array '{ LSHandlerContentType = "xxxx"; LSHandlerRoleAll = "com.xxx.xxx"; }';
    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchS ervices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user;
    please help

    my app to be default for the that document type forcefully.
    This is requirement of my client. I want same effect as of "clicking change all button by selecting default application" when we right click the file with that extension. 
    Please help if you know how to do it??

  • Hi,plz help me,iam not using mozilla bcoz i've problem in opening in my pc,it takes nearly 45 sec to open when i open for th first time after switching on my pc, so i use chrome,opera.plz sugesst some help so that i can start using again my mozilla.

    opening mozilla a big headace for me because it load very lately,i have 2gb ram and amd 4800+ processor

    Genieo definitely doesn't help with your router. It's just adware, and has no benefit to you at all. They scammed you so that they could display their ads on your computer.
    To remove it, see:
    http://www.thesafemac.com/arg-genieo/
    Do not use the Genieo uninstaller!

  • HT1338 PLEASE HELP ME I AM FACING A PROBLEM My name is Ameer. I watch youtube videos from ipad2 ( safari ) today for my first time, when i run a video and i want to pause it, i touch the screen where the video is playing to reach the pause botton that is

    PLEASE HELP ME I AM FACING A PROBLEM
    My name is Ameer.
    I watch youtube videos from ipad2 ( safari )
    today for my first time, when i run a video and i want to pause it, i touch the screen where the video is playing to reach the pause botton that is located on a bar under the video which appears when i touch the screen. Today every time i touch the screen nothing happens and i cannt pause the video nor adjusting its quality.
    So plese help me fixing this problem as soon as posible.
    Regards

    Same problem on my ipad mini, running ios 6.0.2.
    A bit more info:
    -tried using YouTube in Safari on another ipad. Worked fine.
    Tried reboot (sleep + home buttons for 15 seconds). Didn't fix.
    -tried logging out of my YouTube account, thinking the problem was tied to my settings. Didn't fix.
    -tried uninstalling all apps I downloaded since the last time YouTube worked properly. Didn't fix.
    -tried watching a video in desktop mode. Can tap video screen to bring up pause okay in that mode.
    There are work arounds, but the thing I want to know is why YouTube doesn't work in Safari as of a couple of days ago, and is it indicative of another more serious problem with my ipad.

  • My iphone 6plus not working not charge but when i run it the first time working half an hour  when you attempt to run it again light up thr screen and showws the apple logo and after the pice screen illuminates red and does not work what do i do now

    My iphone 6plus not working not charge but when i run it the first time working half an hour  when you attempt to run it again light up thr screen and showws the apple logo and after the pice screen illuminates red and does not work what do i do now

    Hello Nadersalah,
    It seems you're experiencing multiple issue with your iPhone. Based on the information you have provided, it appears your iPhone needs to be serviced. The following link should help you get started with the process and has links with additional information on topics such as warranty and service pricing, battery replacement, and express replacement service.
    iPhone Repair and Service - Apple Support
    Thank you for contributing to Apple Support Communities.
    Cheers,
    Bobby_D

  • Hi i want to use boot camp for the first time but i was wondering if when you install windows in your mac there is any risk of virus?

    hi i want to use boot camp for the first time but i was wondering if when you install windows in your mac there is any risk of virus?

    angelicagalera wrote:
    hi i want to use boot camp for the first time but i was wondering if when you install windows in your mac there is any risk of virus?
    Of course there is. There is with any computer system that you connect to the internet or transfers files to and from. When you run Windows on your Mac you increase the chance from zero that you will get a Windows based virus to virtualy the same risk as any other Windows user.
    The weaknesses in Windows OS and applications are well trodden by virus and worm malcontents the world over. That doesn't mean that OSX is exempt though. All it will take is once and the entire Mac world will sit up and take notice......
    Rick

  • Page with PartialTriggers is not working when it loads for the first time

    Hi All,
    I am experiencing unexpected behavior when using partial triggers and this recurres every time the page loads and the second time it works fine.
    Here is the requirement, The page has a check box, when checked, two text boxes should be disabled. When unchecked the two fields should be enabled.
    (The fields are Start Date Time and End Date Time in the code below). I am also handiling the Date Validations on value change listener of Start Date time and have no issues on that.
    When I try to enter the dates on page load (The check box - "Process Full Indicator" is not selected), I enter the required fields (PEID, Dates and check the Process IAF and Process SMS check boxes and click on the ProcessRFI Button, the date fields are emptied and nothing happens. When i redo the same thing the second time, it works.
    The button invokes a BEPL process.
    One of the links suggested that I use the partialTrigger tag in the parent layout, I used in the panelFormLayout and it sill did not reflect.
    I am facing the same issue in an other page that is reteriving data from a DB Table. As I notice, both the pages are invoking dataControlls. Not too sure if it is related.
    Kindly help.
    <af:panelFormLayout id="pfl1"
    inlineStyle="font-weight:bold; height:181px;"
    >
    <af:inputText value="#{bindings.PEID.inputValue}"
    label="PEID"
    required="#{bindings.PEID.hints.mandatory}"
    columns="#{bindings.PEID.hints.displayWidth}"
    maximumLength="#{bindings.PEID.hints.precision}"
    shortDesc="#{bindings.PEID.hints.tooltip}" id="it1"
    inlineStyle="font-weight:bold;">
    <f:validator binding="#{bindings.PEID.validator}"/>
    </af:inputText>
    <!--af:inputText value="#{bindings.EnrichmentBatchID.inputValue}"
    label="Enrichment Batch ID"
    required="#{bindings.EnrichmentBatchID.hints.mandatory}"
    columns="#{bindings.EnrichmentBatchID.hints.displayWidth}"
    maximumLength="#{bindings.EnrichmentBatchID.hints.precision}"
    shortDesc="#{bindings.EnrichmentBatchID.hints.tooltip}"
    id="it3">
    <f:validator binding="#{bindings.EnrichmentBatchID.validator}"/>
    </af:inputText-->
    <af:inputDate value="#{bindings.StartDateTime.inputValue}"
    label="Start Date Time"
    shortDesc="#{bindings.StartDateTime.hints.tooltip}"
    id="id1" inlineStyle="font-weight:bold;"
    binding="#{backing_ProcessRFI.input_startDate}"
    valueChangeListener="#{backing_ProcessRFI.assignFromDateValue}"
    autoSubmit="true"
    required="true" immediate="true">
    <f:validator binding="#{bindings.StartDateTime.validator}"/>
    <af:convertDateTime pattern="#{bindings.StartDateTime.format}" type="both"/>
    </af:inputDate>
    <af:inputDate value="#{bindings.EndDateTime.inputValue}"
    label="End Date Time"
    shortDesc="#{bindings.EndDateTime.hints.tooltip}"
    id="id2" inlineStyle="font-weight:bold;"
    binding="#{backing_ProcessRFI.input_endDate}"
    partialTriggers="id1"
    required="true"
    valueChangeListener="#{backing_ProcessRFI.checkNullStartDateValue}"
    autoSubmit="true" immediate="true">
    <af:validateDateTimeRange minimum="#{backing_ProcessRFI.dtFromDate}"
    hintMinimum="End date should be greater than the Start Date"
    />
    <f:validator binding="#{bindings.EndDateTime.validator}"/>
    <af:convertDateTime pattern="#{bindings.EndDateTime.format}" type="both"/>
    </af:inputDate>
    <af:selectBooleanCheckbox value="#{bindings.ProcessIAFIndicator.inputValue}"
    label="Process IAF"
    required="#{bindings.ProcessIAFIndicator.hints.mandatory}"
    shortDesc="#{bindings.ProcessIAFIndicator.hints.tooltip}"
    id="it2"
    inlineStyle="font-weight:bold;">
    <f:validator binding="#{bindings.ProcessIAFIndicator.validator}"/>
    </af:selectBooleanCheckbox>
    <af:selectBooleanCheckbox value="#{bindings.ProcessSMSIndicator.inputValue}"
    label="Process SMS"
    required="#{bindings.ProcessSMSIndicator.hints.mandatory}"
    shortDesc="#{bindings.ProcessSMSIndicator.hints.tooltip}"
    id="it5"
    inlineStyle="font-weight:bold;">
    <f:validator binding="#{bindings.ProcessSMSIndicator.validator}"/>
    </af:selectBooleanCheckbox>
    <af:selectBooleanCheckbox value="#{bindings.ProcessFullIndicator.inputValue}"
    label="Process Full Indicator"
    required="#{bindings.ProcessFullIndicator.hints.mandatory}"
    shortDesc="#{bindings.ProcessFullIndicator.hints.tooltip}"
    id="it4"
    inlineStyle="font-weight:bold;"
    binding="#{backing_ProcessRFI.processFullIndicator}"
    valueChangeListener="#{backing_ProcessRFI.handleFullIndicator}"
    autoSubmit="true">
    <f:validator binding="#{bindings.ProcessFullIndicator.validator}"/>
    </af:selectBooleanCheckbox>
    <af:panelStretchLayout id="psl1" inlineStyle="height:40px;">
    <f:facet name="center">
    <af:panelGroupLayout layout="horizontal"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
    id="pgl2">
    <af:commandButton actionListener="#{bindings.ProcessRFI.execute}"
    text="Process RFI"
    disabled="#{!bindings.ProcessRFI.enabled}"
    id="cb2"
    attributeChangeListener="#{ProcessRFI.processResult}"/>
    <af:resetButton text="Clear" id="rb1"/>
    <f:facet name="separator">
    <af:spacer width="10" height="10" id="s2"/>
    </f:facet>
    </af:panelGroupLayout>
    </f:facet>
    </af:panelStretchLayout>
    </af:panelFormLayout>

    Hi John,
    My page is not a part of a task flow. The whole app is an Admin app comprising of multiple individual pages navigated using Menu.
    I have tried to run this page individually on my local machine as well as when deployed on the WLS server. The behavior is the same.
    Kindly advice,
    Thanks,
    Ram

  • I downloded iphoto 11 9.2 and when opened it for the first time and the program started to update my iPhoto library the file got corrupted. That has happened in the two macs I have (both of them rather new and updated to last Lion version 10.7.2).

    I downloaded Iphoto 11 9.2 from the apps store (was on iphoto '09 before version 8.x) and when opened it for the first time it tried to update my photo librery and ended up corupting it to the extreme that I had to get a backup from time capsule and downgrade my iphoto version. I spent yesterday 6 hours at the genius bar in an apple store and they were not able to provide me with any other solution. In the emantime, I have to forget about about photo streaming... Any idea, is this a bug that somebody knows how tp fix?

    In fairness, this isn't an issue in iPhoto 11 but one in your Library. Some file or other in there is damaged and that's what causes the crash during the upgrade.
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.  

  • How to find that a java program is running for the first time on daily basi

    it is like this
    1. i will ran a java program every day and i have to find that it is running for the first time(as i may stop that program and may run again the same day )
    Pls share ur ideas

    san.kumar wrote:
    it is like this
    1. i will ran a java program every day and i have to find that it is running for the first time(as i may stop that program and may run again the same day )
    Pls share ur ideasAs kajbj said - you need to store a token / file with a run date on the file system. Each time the application runs, have it compare with the date from this file with the current date. If different, it's the first run of the day. If not, it is not the first run of the day. Each time have it update the date on the file.

  • How come my safari windows disappear when I close my laptop and open again? The safari windows I wanted to keep running for the next time I open my laptop disappeared. Why? Help me.

    How come my safari windows disappear when I close my laptop and open again? The safari windows I wanted to keep running for the next time I open my laptop disappeared. Why? Help me.

    Important note, do NOT sleep your macbook Air with headphones attached until this is resolved.
    Ive done a good best of testing on same to confirm not to do that
    also if you have the APP "BOOM" installed........ remove it

  • TS1292 i have an itunes card that when scratching off for the code some of the numbers rubbed off.  This was a gift so i really dont want to ask for a receipt.  Any suggestions?

    i have an itunes card that when scratching off for the code some of the numbers rubbed off.  This was a gift so i really dont want to ask for a receipt.  Any suggestions?

    Click here and ask the iTunes Store staff for assistance. Supply them with as much of the code as you can.
    (97364)

Maybe you are looking for

  • My external hard drive worked on my old macbook but not on my new one. Why?

    I have an older macbook (white plastic case) and Just got the newest Macbook Pro (Mid 2014). My external hard drive, WD My Passport 1TB, worked just fine on the previous computer but now when I plug it into the new macbook, it doesn't pop up. Additio

  • How to display confirm message in APEX pl/sql process

    I have a pl/sql process that selects success messages from a database table. These messages need to be displayed to the user and confirmed (only one button, to acknowledge/dismiss the mssage) along the way. Is there a way to do this within the proces

  • Fm or class existing for fetching xml contents from a file using abap ?

    Hi, I need to fetch an xml file in a string of type xstring. I am using class cl_gui_frontend_services=>gui_upload. This returns me content in table format, than i am planning to conver to xstring. Is there any better approach or any existing functio

  • Can a CIN be written for Visual Basic code

    I've read about C code and CIN usage and seen references to other languages such as Visual Basic (Visual Studio- don't have NET yet). Is the only way to create a dll?

  • UPS shutting down iMac

    I need some help. I have an iMac 21" (brand new). For some reason the computer goes to sleep and then shuts down completely. I am assuming it has something to do with the UPS setting in the system preferences. My question is 1. how doe I set them cor