+ Reply to Thread
Results 1 to 7 of 7

Compile Error while checking if worksheet exists....

  1. #1
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Compile Error while checking if worksheet exists....

    Hello,

    I have a slight problem. Whenever I run the code below I get an error Message: "Compile Error ByRef argument type mismatch" And the Sheet9 (marked in red here) is marked yellow in the debugging mode.

    Obviously my code there is not valid but how to modify it so that it will work?

    Just in case it is not Clear what I want to achieve is simply that I want the Macro to check IF there is a Sheet9 (IF it exists in the WorkBook) and if YES then add it as a PDF attachement as well. If it does NOT exists then go on With the macro.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Compile Error while checking if worksheet exists....

    Try changing your SaveAsPDF sub to:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Compile Error while checking if worksheet exists....

    Ok tried that but now I get the following error:

    Runtime error 429;
    ActiveX Component can´t create Object

    And the following part of the code is then highlighted yellow in the debugger:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Compile Error while checking if worksheet exists....

    Not exactly sure what's the problem as I don't use Outlook, but Google search results showed this.

  5. #5
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Compile Error while checking if worksheet exists....

    Oh I´m sorry. I did it on the wrong computer where there is no Outlook installed....hahahaha


    I corrected it now and used my CORRECT computer. Following Your advise by adding ByVal the Macro DOES run without a any errors, BUT by adding the ByVal the PDF attachements are NOT added


    I can see the pop up publishing dialog that the PDF´s are beeing created like always but when done the attachements are not added.


    I´m guessing that there should be some more modification necessary in the code when ByVal is added in the Sub??

  6. #6
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Compile Error while checking if worksheet exists....

    Just noticed that you are actually setting the path name in the SaveAsPDF sub, so try changing to this instead:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Compile Error while checking if worksheet exists....

    Thanks, that fixed the problem of this post

    I ran into another Challenge that I don´t like, but will post in a New post.

    The IF Sheetx.Visible......statements do not work like i´d hoped.

    Will need to hide unneccessary sheets befor the .attachements.add and then unhide them again afterwords just before End Sub instead i Guess.


    But you solved this problem though so thank you for that man

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  2. Replies: 3
    Last Post: 10-25-2011, 02:12 PM
  3. compile error after editing VBA so graphs are independent of the worksheet
    By kjiratsiekoedel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-03-2009, 09:46 AM
  4. Trying to determine if worksheet exists, subscript out of range error
    By js999 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2007, 12:03 PM
  5. Checking to see if a worksheet exists
    By Raman325 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-19-2005, 02:05 PM

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