Run time error 13

Posted on 2012-09-09
Last Modified: 2012-09-09
Running MS Word 2003 and have a line of code that I'm getting  Run time Error 13, type mismatch.  If I place a break point on the line and execute the code... when it hits the line I continue exuection and the code runs fine.  If I remove the break point and let it run, I get the error??????

Any ideas?

HoursWorked = Trim(Right(SearchString, 8))

Question by:thandel
    LVL 59

    Expert Comment

    by:Chris Bottomley
    Is the variable type numerical and can you be sure the substrong is numerical

    Author Comment

    SearchString is a string but after right/triming its a number... besides why would stepping through it work and full execution not?
    LVL 59

    Accepted Solution

    >>> besides why would stepping through it work and full execution not?

    Not sure but I was asking after HoursWorked ... for example if the trimmed variable SearchString is blank then the 'conversion' would fail.

    try for example

    dim tmp as variant
    tmp = Trim(Right(SearchString, 8))
    if tmp = "" then
        HoursWorked = 0
    elseif isnumeric(tmp) then
        HoursWorked = 0
    end if

    Open in new window

    And does it still fail?


    Author Comment

    I'll look into why but a variable is not getting set "SearchString" however it is when I setp through it.  Your solution helps as a "band aid" but I can't see why its not getting set.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
    Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
    This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
    This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

    758 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

    10 Experts available now in Live!

    Get 1:1 Help Now