+ Reply to Thread
Results 1 to 3 of 3

Compile error after including a Function in my code

  1. #1
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Compile error after including a Function in my code

    Hi all,

    I have a program I have been working on for some time that works in the OneDrive environment. I grabbed some code online to be able to save a PDF of a worksheet while offline in a file on OneDrive and ever since I a reoccurring compile error:

    Capture.GIF

    Generally if I comment out the code and then compile the program compiles, I then un comment the code and then compile again and good to go. Maybe two weeks later the same thing happens and I repeat the process and it works again for a while.

    This is the function:

    Please Login or Register  to view this content.
    and this is how I call it:

    Please Login or Register  to view this content.
    FilePath is Dimmed as a string.

    Can anyone see anything wrong with this code that could be causing the error or maybe a better way to achieve the same result?

    Kind regards,
    Marcus

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Compile error after including a Function in my code

    The error message says that the compile error is in ThisWorkbook. Is that where the function is? Is there any other code in ThisWorkbook? If so please show all the code in ThisWorkbook.

    The error you get is unusual. Normally a compile error will result in a dialog box that allows you to enter the VBA environment, shows you where the error is, and allows you to debug.

    Is it possible for you to attach your file?

  3. #3
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Re: Compile error after including a Function in my code

    Hi there,

    There's probably 50k lines of code so no point attaching the whole WB or the code. The error only started appearing after I added this Function and its related call. Mostly it does go to a point in the code and the error is that a particular sub that gets called in another module is undefined. It is a sub that has been in the code for years and has always worked with no issues. I generally stop the code, comment out the above code and re compile which works fine, then uncomment the above code and compile again. Program then works for another week or so and then same thing.

    It almost always happens if I do not compile the code before closing the program if I have been working on the code. On open I get the error, however if I compile before closing the error will not appear.

    Its quite strange but hoping someone has experienced something like this before..

    Kind regards,
    Marcus

+ 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 syntax error - spellnumber microsoft code
    By sunboy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-13-2022, 02:53 AM
  2. Replies: 5
    Last Post: 11-28-2019, 04:55 AM
  3. [SOLVED] Function Error: Compile error: Expected: list separator or )
    By goss in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-05-2014, 02:10 PM
  4. [SOLVED] Compile Error 'Sub or Function is not define' error on Private Sub Getdata()
    By HafizuddinLowhim in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2014, 11:17 AM
  5. [SOLVED] Error in function Compile error: Can't find project or library
    By Motario1 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-12-2013, 02:20 AM
  6. code generating compile error: syntex error
    By sankarsasmal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2013, 05:29 AM
  7. [SOLVED] Trying to use INDEX function in VBA Code, compile error
    By Finny in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-26-2006, 02:20 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