Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't exit design mode because Control 'Commandbutton1' can not be cre

Status
Not open for further replies.

YACHTIE

Technical User
Feb 17, 2004
77
CA

Hello,
I keep getting messages (error) that don't make sense,like the one in the subject line. Tried same code in another document (also with forms) but don't get that message but code won't run. am running Word 2002 with office SP3 have used macro recorder to get the following code.
Anything wrong with this code ?

Selection.MoveRight Unit:=wdCharacter, Count:=9, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.PasteAppendTable

Basically all I am trying to accomplish is when user presses a commandbutton on the form, this code adds a new row in a table.

TIA
 
Thanks calculus, however I have solved the problem as follows since the table is formatted with formfields I felt is simpler (from my limited VBA capability anyway)to do the copy and paste routine, see below and this particular error was related to some corrupted document porblem as I have this working in another(same) document, with one minor deficiency. Whic is that after the user actually fills in the data into the formfields, they are also copied over now I need a simple method to clear those entries after the paste command.
Any suggestions???
Code:
    ActiveDocument.Unprotect
'Position cursor in table
' Created bookmark (Text32) in last row first cell
    ActiveDocument.Bookmarks("Text32").Range.Fields(1).Result.Select
    Selection.MoveRight Unit:=wdCharacter, Count:=9, Extend:=wdExtend
    Selection.Copy
    Selection.MoveDown Unit:=wdLine, Count:=1
    Selection.PasteAppendTable
   ' ActiveDocument.FormFields(1).TextInput.Clear

     ' Lock the document
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top