+ Reply to Thread
Results 1 to 6 of 6

Run time error:1004 "Application defined or Object defined error"

  1. #1
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Unhappy Run time error:1004 "Application defined or Object defined error"

    I am trying to open a word template from excel using the vba code. The main logic of the code is that it opens a word template (that has the bookmarks in it) and the active workbook has 3 sheets such as setup sheet, dashboard sheet, codeinfo. The setup sheet has the details of the column number of the data to be populated from the sheet "dashboard sheet" and its bookmark name and its description. The dashboard sheet has the required data starting from row 4 to be populated to word document. the codeinfo sheet has the name of the template document and the name of the folder in which it saves the completed reports. My problem is that When I execute the following code it gives me an error "Run-time error: Application-defined or object-defined error" and stops the execution with one word document "Document 1" that follows the template populated with value. The error happens while looping over the second row data and stops execution. Finally I get an error in the red line while looping for the second bmkname. Thanks.
    Please Login or Register  to view this content.
    Please find the attached workbook. I am not able to upload the word template (.dotx) file since it is not supporting. Please help.
    Attached Files Attached Files
    Last edited by mvneema; 03-06-2014 at 06:03 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,296

    Re: Run time error:1004 "Application defined or Object defined error"

    Try zipping the template up and uploading the zip file.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Run time error:1004 "Application defined or Object defined error"

    I have uploaded the word template. Thanks.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,296

    Re: Run time error:1004 "Application defined or Object defined error"

    I can't test it fully because I don't have the folder structure.

    First note: the code should be in a standard module, not in the Workbook Class Module

    Second Note: you should always put "Option Explicit" (no quote marks) at the top of every code module. This will ensure that all variable are defined and should avoid typos ... like below.

    Third note: I've changed it to Late Binding so I don't need the reference to the Word Library.

    But the problem, I think, was this:

    Please Login or Register  to view this content.

    In the second line, which was commented out, you had "bnkname" instead of "bmkname"

    Try:

    Please Login or Register  to view this content.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Run time error:1004 "Application defined or Object defined error"

    Thank you. i made some silly mistakes while updating the variables. it worked

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,296

    Re: Run time error:1004 "Application defined or Object defined error"

    You're welcome.

+ 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] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  2. Error When Implementing Code: "1004 - Application-defined or object-defined error"
    By blueblazingdemon in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-10-2013, 11:21 AM
  3. Replies: 1
    Last Post: 05-06-2013, 06:07 AM
  4. Run-time error "1004" Application defined or object-define-error
    By josros60 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-21-2013, 01:14 PM
  5. [SOLVED] 1004 "Application-defined or object-defined error"
    By guiu in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-12-2006, 10:45 AM

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