I'm new to vb so it is no surprise that I am stuck. I have this code and it runs as it should but I get a the Error "Run-time error '91: Object variable or With block variable not set". How can I fix this and have it continue on to the rest of my code.
Thank You,
DS

 Do
        Selection.Rows(1).Next.Select
        Selection.Cells(5).Select
        Selection.FormFields.Add Range:=Selection.Range, Type:= _
        wdFieldFormTextInput

        If Selection.Information(wdWithInTable) = True Then
        End If

   Loop Until Selection.Information(wdWithInTable) = False

Recommended Answers

All 4 Replies

It's because you did not make your do loop correctly
look at the proper syntax of the do/untill loop.
http://www.java2s.com/Code/VB/Language-Basics/DoUntilLoop.htm

commented: Invalid post. You should read on how to write a while statement before posting that one is incorrect when its perfectly fine. -2

Incorrect. This is a perfectly valid implementation of a do loop. It is valid (and sometimes desirable) to put the test at the bottom of the loop.

Member Avatar for Unhnd_Exception

My down vote got cut off. So I had to finish it with a post.

@ret801

Heres an excerpt from the directions on a while statement. This comes from Microsoft. Not some wanna be website: a.k.a. java2s.com. Maybe you should find some better resources.

Do { While | Until } condition
    [ statements ]
    [ Exit Do ]
    [ statements ]
Loop
-or-
Do
    [ statements ]
    [ Exit Do ]
    [ statements ]
Loop { While | Until } condition
commented: nice and complete reply +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.