+ Reply to Thread
Results 1 to 8 of 8

Excel - Controlling word - Object Error

  1. #1
    Registered User
    Join Date
    02-17-2008
    Posts
    32

    Excel - Controlling word - Object Error

    Hey guys,

    Having a slight problem with some code that that copies some cells on to a template sheet, and then that template sheet into word and save a doc.

    this is the code - I highlighted the dodgy bit in red:

    Please Login or Register  to view this content.
    I'm sure I have set the object up but I get the error:

    Object variable not set (Error 91)

    Can anyone see why it would be doing that?

    Thanks! I'm so close

    (I'll attach my sheet to make it easier if needed)
    Attached Files Attached Files

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Excel - Controlling word - Object Error

    You are returning a row number, not a range, so you should declare the FinalRow variable as Long, not as Range:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    02-17-2008
    Posts
    32

    Re: Excel - Controlling word - Object Error

    lol now I just feel like a dumbass :D

    Thanks a lot that works perfectly.

    Just one more thing: is there a way to make my code save the docs in a specific folder and have a name that refers to a cell?

    I would assume that I have to edit this line of code:

    Please Login or Register  to view this content.
    I know you could just put the cell but then it would use that cell for all the files, and this macro makes multiple word docs so it baffles me a tad.


  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Excel - Controlling word - Object Error

    So how do you want to construct the filename exactly?

  5. #5
    Registered User
    Join Date
    02-17-2008
    Posts
    32

    Re: Excel - Controlling word - Object Error

    Well in the spreadsheet there is a sheet called 'Data' and if I could I would like it to be the 'User ID' & .doc if you get what I mean

    So for example cs205189.docx

    And so on for each one so they are named after the persons Student ID
    Last edited by dntel123; 09-28-2009 at 10:57 AM. Reason: Speeling mistake

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Excel - Controlling word - Object Error

    Not really! I guess something like:
    Please Login or Register  to view this content.
    ?

  7. #7
    Registered User
    Join Date
    02-17-2008
    Posts
    32

    Re: Excel - Controlling word - Object Error

    lol nope got a massive error

    What would happen if I leave off

    Please Login or Register  to view this content.
    Would it ask me to save it somewhere? Spose if u had 100 though you would have to click 100 times.

    I'll have a play thanks for the help anyway!

  8. #8
    Registered User
    Join Date
    02-17-2008
    Posts
    32

    Re: Excel - Controlling word - Object Error

    Woh woah hang on

    Please Login or Register  to view this content.
    that works

    Names them correctly

+ 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