Results 1 to 4 of 4

Thread: I get "Object variable or With block variable not set" error

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    2

    I get "Object variable or With block variable not set" error

    I get the error described in the title when executing the code beneath. Any help would be appreciated.

    VB Code:
    1. Public Sub AutoNew()
    2.  
    3.     Dim PlayName
    4.     PlayName = InputBox("Enter Name of Play", "Name of Play")
    5.     If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
    6.         ActiveWindow.Panes(2).Close
    7.     End If
    8.     If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    9.         ActivePane.View.Type = wdOutlineView Then
    10.         ActiveWindow.ActivePane.View.Type = wdPrintView
    11.     End If
    12.     ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    13.     Selection.TypeText Text:=PlayName & vbTab & vbTab
    14.     Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldPage
    15.     ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    16. End Sub

    Port

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: I get "Object variable or With block variable not set" error

    on what line?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    2

    Re: I get "Object variable or With block variable not set" error

    It does not provide a line number. I just get a message box that appears with the error message. i'm new to VBA and VB in general, but am an experienced programmer in other languages.

    Is there a way to get a more detailed message?

    Port

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: I get "Object variable or With block variable not set" error

    it wont provide line numbers.. but it should highlight the line showing the error.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width