+ Reply to Thread
Results 1 to 9 of 9

Run-time error 91 object variable or with block varialbe not set

  1. #1
    Registered User
    Join Date
    12-14-2013
    Location
    OKC
    MS-Off Ver
    2010
    Posts
    9

    Run-time error 91 object variable or with block varialbe not set

    In Microsoft word I am recieving the Run-time error 91. this is the problem I put the code into a word document all by it's self and it works fine, when I moved the code over to my actuall project i started receiving this error and I can not figure this out. Does anyone have any suggestions? I am really stuck on this.

    [code]
    Private Sub Document_Open()
    Application.WindowState = wdWindowStateMinimize
    UserForm1.Show vbModeless
    End Sub
    [code]

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Run-time error 91 object variable or with block varialbe not set

    Which line of code is highlighted when you get the error and click Debug?

    Is it this one?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-14-2013
    Location
    OKC
    MS-Off Ver
    2010
    Posts
    9

    Re: Run-time error 91 object variable or with block varialbe not set

    yes it it's the userform1.show vbmodeless it debugs on, but only in my actual project. if i put the code in a document by it's self it works great.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Run-time error 91 object variable or with block varialbe not set

    When you get an error like that the problem is usually in any code that is run when the userform is shown.

    For example, code in its Initialize or Activate event.

    Do you have any code there?

  5. #5
    Registered User
    Join Date
    12-14-2013
    Location
    OKC
    MS-Off Ver
    2010
    Posts
    9

    Re: Run-time error 91 object variable or with block varialbe not set

    Yes,
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-14-2013
    Location
    OKC
    MS-Off Ver
    2010
    Posts
    9

    Re: Run-time error 91 object variable or with block varialbe not set

    I removed the code from the userform and I am no longer receiving the error. But now it's not doing what I wanted it to do. Which is hide the word program it is running from. It hides until you open another word document. then it appears and if you minimize it you lose the userform. I am not understanding why it works when it's by it's self but not when I put it in my actual project. any thoughts on that?

  7. #7
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Run-time error 91 object variable or with block varialbe not set

    Cross-posted at: http://www.msofficeforums.com/word-v...le-bolock.html
    For cross-posting etiquette, please read FORUM RULE 8: http://www.excelforum.com/forum-rule...rum-rules.html
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  8. #8
    Registered User
    Join Date
    12-14-2013
    Location
    OKC
    MS-Off Ver
    2010
    Posts
    9

    Re: Run-time error 91 object variable or with block varialbe not set

    That was not me - that was the person I am working with on this project. She has her sites she uses and I have mine. She didn't tell me she posted for assistance.

  9. #9
    Registered User
    Join Date
    12-14-2013
    Location
    OKC
    MS-Off Ver
    2010
    Posts
    9

    Re: Run-time error 91 object variable or with block varialbe not set

    I found the problem - It was my mistake - thank you Norie for your assistance it was the information that you provided that brought my error to light. I had forgotten I changed the name of the object, So I was not referance the correct object in my project. I changed the name back to ThisDocument and now everything is working great. Again Thanks a million for your assistance.

+ 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] New Error/Old Code - Run Time Error 91; Object variable or With block variable not set
    By humboldtguy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-15-2014, 12:39 AM
  2. Replies: 0
    Last Post: 04-16-2013, 07:15 AM
  3. Replies: 6
    Last Post: 12-21-2012, 08:03 AM
  4. Replies: 1
    Last Post: 09-25-2012, 08:03 PM
  5. [SOLVED] Intermittent Run-time Error 91: Object Variable or With Block variable not set
    By fraanchtoast in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-29-2012, 10:11 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