+ Reply to Thread
Results 1 to 7 of 7

Break long lines of code, Map enter key with OnKey

  1. #1
    Registered User
    Join Date
    02-02-2012
    Location
    Orlando, FL
    MS-Off Ver
    Excel 2011
    Posts
    16

    Break long lines of code, Map enter key with OnKey

    I get the error message "illegal character" when I use the underscore character to break a long line of code into two or more shorter lines.

    My full macro was originally written with Excel 2003. The underscore character works in that portion of the code. I'm adding some lines to the macro with Excel 2011. I get the error message in the new portion. How do I break lines in Excel VBA 2011? I use the file type ".xlsm" to save and run macros in Excel 2011. It uses the same Personal Macro Workbook and most of my other macros work. They do not recognize the equivalent keys, for example, CMD-OPT-b

    I tried to use ONKEY to call with the FUNCTION key, but it doesn't work:
    Please Login or Register  to view this content.
    This worked until I saved, quit, and restarted.

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Break long lines of code, Map enter key with OnKey

    The underscore is still the line continuation character in 2011. What was the line of code you tried to break (and where did you put the underscore)?
    Good luck.

  3. #3
    Registered User
    Join Date
    02-02-2012
    Location
    Orlando, FL
    MS-Off Ver
    Excel 2011
    Posts
    16

    Re: Break long lines of code, Map enter key with OnKey

    ActiveChart.Shapes.AddTextbox(msoTextOrientationHorizontal, 467, 9, 180, 140).TextFrame.Characters.Text = "WIRELESS ENGINEEERING CORP. ORLANDO, FL 32819 Date Job#: P/N: S/N: Pattern: Cut: Polarization: Gain: Engr: EPA "

    I added yhe underscore between Characters and .Text:
    Characters. _ Text
    Last edited by capngene; 02-02-2012 at 06:48 PM. Reason: Forgot to fully answer query

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Break long lines of code, Map enter key with OnKey

    Where did you put the underscore? Within the string value perchance?

  5. #5
    Registered User
    Join Date
    02-02-2012
    Location
    Orlando, FL
    MS-Off Ver
    Excel 2011
    Posts
    16

    Re: Break long lines of code, Map enter key with OnKey

    I put it in the same relative position as it is in some of my old macros, after a "." and before the next operation with spaces around it, also without the spaces.

    Characters. _ Text

  6. #6
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Break long lines of code, Map enter key with OnKey

    That works fine for me (I am assuming you actually pressed return between the underscore and the word Text - you would get an invalid character error if they are on the same line)

  7. #7
    Registered User
    Join Date
    02-02-2012
    Location
    Orlando, FL
    MS-Off Ver
    Excel 2011
    Posts
    16

    Re: Break long lines of code, Map enter key with OnKey

    I had it on the same line, Thanks for the tip to put the return in the line. (Now I feel stupid!)

    Thanks for the help.

    Any suggestions for the OnKey problem?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1