+ Reply to Thread
Results 1 to 6 of 6

Adding Header via Add-In - Compile error: Type Mismatch

  1. #1
    Forum Contributor
    Join Date
    09-13-2008
    Location
    Los Angeles, CA
    MS-Off Ver
    365
    Posts
    120

    Adding Header via Add-In - Compile error: Type Mismatch

    I wrote a macro that basically adds 5 lines at the beginning and puts in a heading (don't want to use headers). The macro worked flawlessly, then i decided to add it to my add-in and now I get the compile error "type mismatch" for the following line

    Range("A1").Select
    - the "A1" is highlighted in particular.

    Here is the entire code:

    Rows("1:5").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "1"
    With Selection.Font
    .Color = -16776961
    .TintAndShade = 0
    End With
    Selection.Font.Bold = True
    Range("A2").Select
    ActiveCell.FormulaR1C1 = "2"
    Selection.Font.Bold = True
    Range("A3").Select
    ActiveCell.FormulaR1C1 = "3"
    Selection.Font.Bold = True
    Range("A4").Select
    Selection.NumberFormat = "mm/dd/yy"
    ActiveCell.FormulaR1C1 = "4"
    With Selection
    .HorizontalAlignment = xlLeft
    .VerticalAlignment = xlBottom
    .WrapText = False
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = False
    End With
    Selection.Font.Bold = True
    Range("A5").Select
    ActiveCell.FormulaR1C1 = "5"
    Selection.Font.Bold = True
    With Selection.Font
    .Color = -16776961
    .TintAndShade = 0
    End With
    Any help will be greatly appreciated!
    Last edited by koticphreak; 08-01-2009 at 12:13 PM.

  2. #2
    Forum Contributor
    Join Date
    09-13-2008
    Location
    Los Angeles, CA
    MS-Off Ver
    365
    Posts
    120

    Re: Adding Header via Add-In - Compile error: Type Mismatch

    little help?

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,429

    Re: Adding Header via Add-In - Compile error: Type Mismatch

    Do you still get the error if you remove all that selection code?

    Please Login or Register  to view this content.
    If so we need more details as the code itself works.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor
    Join Date
    09-13-2008
    Location
    Los Angeles, CA
    MS-Off Ver
    365
    Posts
    120

    Re: Adding Header via Add-In - Compile error: Type Mismatch

    tried this and am getting the same error on the following line

    With Range("A1")
    with the A1 portion highlighted.

    I've attached the add-in, I'll pm you the password. I really appreciate you taking the time to look into it, thanks!

    p.s. it's the black head icon.
    Attached Files Attached Files
    Last edited by koticphreak; 07-31-2009 at 04:06 PM. Reason: p.s.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,429

    Re: Adding Header via Add-In - Compile error: Type Mismatch

    You have a subroutine named Range, which is causing confusion with the Range object.

    You routine is taking precedent and the type mismatch is caused by you in effect passing a string to a routine that is expecting an IRibbonControl.

    Change the routine to something like RangeX.

  6. #6
    Forum Contributor
    Join Date
    09-13-2008
    Location
    Los Angeles, CA
    MS-Off Ver
    365
    Posts
    120

    Re: Adding Header via Add-In - Compile error: Type Mismatch

    should have known it was something like that! thanks so much!

+ 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