Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / September 2007

Tip: Looking for answers? Try searching our database.

What is Run Time Error 6028?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan the Man - 16 Sep 2007 02:42 GMT
Don't know if anyone can help me with this or not.

I have a Userform on my spreadsheet for inputing "comments" into. This form
also has a variety of function buttons on it which work just fine, with the
exception of 2 of those buttons (Post Comments, and Update Comments).
Whenever I attempt to "click" on either Post or Update Comments, I receive
the following popup: "Run Time Error 6028: The Range Cannot Be Deleted". I'm
not exactly sure what this message means, or how to rectify the problem.

If someone could give me an idea of what I need to look for in order to
attack this problem I would appreciate it.

Thanks,

Dan
Barb Reinhardt - 16 Sep 2007 13:04 GMT
It might help someone if you posted your code and identified where the error
occurs.
Signature

HTH,
Barb Reinhardt

> Don't know if anyone can help me with this or not.
>
[quoted text clipped - 11 lines]
>
> Dan
Dan the Man - 16 Sep 2007 15:44 GMT
Hi Barb:

Sorry for not including the code which operates my Unserform. The error
seems to occur specifically with respect to the "Post Comments" and "Update
Comments" string of code below (Command Buttons 3 and 4 below). The code
associated with the other buttons works just fine, however when I attempt to
use the "Post Comments" or "Update Comments" buttons I get that nasty Run
Time 6028 Error: "The Range Cannot be Deleted". This code exists in my "Word"
VB editor, and is associated with a Word Document entitled "Sample Note
Updated". While the code is long, the error which highlights (when I choose
Debug) appears specific to the Command Buttons mentioned above. In fact the
line of code (for each command button) that highlights in "yellow" is:
mytable.Cell(nrows + 1, 1) = TextBox1.Text
Thus I suspect that the problem is within that string (I think). I'm a
"noobie" to all of this so I'm sure that doesn't help. Below is the full code
information.

Dan

-----------------------------------------------------------------------------------------------------------
Public nrows As Integer
Public nr As Integer
Public incr As Integer
Public mytable As Object

Private Sub cmbNext_Click()
nr = nr + 1
cmbNext.Visible = True
cmbPrevious.Visible = True
If nr >= nrows Then
   cmbNext.Visible = False
End If
With mytable
   TextBox2.Text = Left(.Cell(nr + 1, 2), Len(.Cell(nr + 1, 2)) - 2)
   TextBox1.Text = Left(.Cell(nr + 1, 1), Len(.Cell(nr + 1, 1)) - 2)
End With
End Sub
Private Sub cmbPrevious_Click()
nr = nr - 1
cmbNext.Visible = True
cmbPrevious.Visible = True
If nr = 1 Then
   cmbPrevious.Visible = False
End If
With mytable
   TextBox2.Text = Left(.Cell(nr + 1, 2), Len(.Cell(nr + 1, 2)) - 2)
   TextBox1.Text = Left(.Cell(nr + 1, 1), Len(.Cell(nr + 1, 1)) - 2)
End With
End Sub

Private Sub cmbPrintComment_Click()

Documents.Add DocumentType:=wdNewBlankDocument

Selection.TypeText Text:="Client Name:  " & TextBox3.Text
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:="Date of Progress Note:  " & TextBox2.Text
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:=TextBox1.Text

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
       wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
       ManualDuplexPrint:=False, Collate:=True, Background:=True,
PrintToFile:= _
       False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
       PrintZoomPaperHeight:=0
     

End Sub

Private Sub cmbPrintAll_Click()
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
       wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
       ManualDuplexPrint:=False, Collate:=True, Background:=True,
PrintToFile:= _
       False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
       PrintZoomPaperHeight:=0
End Sub

Private Sub CommandButton11_Click()
TextBox1.Text = ""
End Sub

Private Sub UserForm_Initialize()
Set mytable = ActiveDocument.Tables(1)
With mytable
   TextBox3.Text = Left(.Cell(1, 1), Len(.Cell(1, 1)) - 2)
   TextBox2.Text = Left(.Cell(2, 2), Len(.Cell(2, 2)) - 2)
   TextBox1.Text = Left(.Cell(2, 1), Len(.Cell(2, 1)) - 2)
   nr = 1
   nrows = 0
   incr = 1
   For n = 2 To .Rows.Count
   If Len(.Cell(n, 1)) <> 2 Then
      nrows = nrows + 1
   End If
   Next n
   cmbPrevious.Visible = False
 
End With
End Sub

Private Sub CommandButton3_Click()
nrows = nrows + 1
mytable.Cell(nrows + 1, 1) = TextBox1.Text
mytable.Cell(nrows + 1, 2) = Now()
incr = 1
nr = nrows
End Sub
Private Sub CommandButton4_Click()
nrows = nr
mytable.Cell(nrows + 1, 1) = TextBox1.Text
mytable.Cell(nrows + 1, 2) = Now()
End Sub
Private Sub CommandButton5_Click()
mytable.Cell(nr + 1, 1).Row.Delete
TextBox1.Text = ""
TextBox2.Text = ""
nrows = nrows - 1
End Sub
Private Sub CommandButton8_Click()
UserForm1.hide
End Sub

> It might help someone if you posted your code and identified where the error
> occurs.
[quoted text clipped - 14 lines]
> >
> > Dan
Barb Reinhardt - 17 Sep 2007 12:54 GMT
The first thing I'd check is the number of rows currently in the table.   Put
this before the error:

Debug.print nrows
Debug.print mytable.rows.count

Signature

HTH,
Barb Reinhardt

> Hi Barb:
>
[quoted text clipped - 142 lines]
> > >
> > > Dan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.