+ Reply to Thread
Results 1 to 7 of 7

"ActiveWorkbook.Path" fails - triggers "Compile Error Object required"

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    "ActiveWorkbook.Path" fails - triggers "Compile Error Object required"

    Apologies if this has been answered already, but couldn't find it if it has.

    Folder contains a Master file with one worksheet. and several other files with multiple sheets.

    Following extract from Master File macro should find and open each file in the Active Workbook folder, but it's throwing an error when setting the current folder path?

    Please Login or Register  to view this content.
    Hope someone can see the problem

    All solutions, suggestions and alternatives welcome as ever

    Ochimis

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: "ActiveWorkbook.Path" fails - triggers "Compile Error Object required"

    Get rid of "set", you don't set a string.
    Also you should have them all dim'd as strings
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    You also need to dim each worksheet as worksheet.
    Last edited by davesexcel; 12-14-2018 at 11:30 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: "ActiveWorkbook.Path" fails - triggers "Compile Error Object required"

    davesexcel,

    Seems that's an error I've been making for ages!

    I was taught moons ago using VB and VB.Net, that linking the multiple names on the one line meant they were all declared as Strings.

    Presumably any other than the last name are now "implicitly" Variants?

    Ochimus

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: "ActiveWorkbook.Path" fails - triggers "Compile Error Object required"

    Sorry, typo, should have said "dim'd" as strings, not "set" as strings, looks like you understood though.

    And you did remove set?
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by davesexcel; 12-14-2018 at 11:39 AM.

  5. #5
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: "ActiveWorkbook.Path" fails - triggers "Compile Error Object required"

    Davesexecel,

    Yes I "Dim'd" each variable separately, and removed the Set ref.

    But code now stops when I try to set the Main file as the Destination workbook. Throws a Runtime Error 91:

    Please Login or Register  to view this content.
    As before, hope someone can help me?

    Ochimus
    Last edited by Ochimus; 12-14-2018 at 07:06 PM.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: "ActiveWorkbook.Path" fails - triggers "Compile Error Object required"

    You dim'd wbDst as a workbook but have told the code it is supposed to be equal to the workbook.name, which would be a string.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    or "Thisworkbook" , most cases thisworkbook would be the one that has the running code.
    You have to set workbooks.

  7. #7
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,394

    Re: "ActiveWorkbook.Path" fails - triggers "Compile Error Object required"

    davesexcel,

    Rescued once again! Seems the "Senior Moments" are becoming more frequent by the week. . .

    Slight Code tweaking means everything now works smoothly, so can mark this as solved, and add it to the Toolbox.

    Ochimus

+ 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] Choice between "Compile Error" and "Error 91 - Object Variable Not Defined"
    By JoeVanGeaux in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-09-2017, 02:56 PM
  2. Excel VBA "Compile Error: Object Reqired"
    By tris123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-11-2016, 10:44 AM
  3. [SOLVED] Setting a range variable to its offset triggers an "Object required" error
    By Durarara in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2016, 01:50 PM
  4. Replies: 35
    Last Post: 01-13-2016, 02:16 AM
  5. Set Variable = File Path generates "Object Required" Error
    By Brian48072 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-30-2013, 11:42 AM
  6. Error msgs: "Object varible or with block variable not set"; "subscript out of range"
    By menyanthe in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-26-2009, 04:58 PM
  7. [SOLVED] What is Error "Method "Paste" of object "_Worksheet" failed?
    By vat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2006, 04:10 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