From: Dan the Man on
Don't know if anyone can help me with this or not.

I have a Userform on my spreadsheet for inputting "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-Button 3, and Update
Comments-Button 4).

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.
This code exists in my "Word" VB editor. The line of code (for each command
button) that highlights in "yellow" (where I suspect is the problem) is:

mytable.Cell(nrows + 1, 1) = TextBox1.Text

If someone could give me an idea of what I need to look for in order to
attack this problem I would appreciate it. 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

From: Jay Freedman on
Try modifying that line to

mytable.Cell(nrows + 1, 1).Range.Text = TextBox1.Text

Make a similar change to all the other lines that try to assign text
to a table cell.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 16 Sep 2007 15:12:01 -0700, Dan the Man
<DantheMan(a)discussions.microsoft.com> wrote:

>Don't know if anyone can help me with this or not.
>
>I have a Userform on my spreadsheet for inputting "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-Button 3, and Update
>Comments-Button 4).
>
>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.
>This code exists in my "Word" VB editor. The line of code (for each command
>button) that highlights in "yellow" (where I suspect is the problem) is:
>
>mytable.Cell(nrows + 1, 1) = TextBox1.Text
>
>If someone could give me an idea of what I need to look for in order to
>attack this problem I would appreciate it. 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
From: Dan the Man on
Jay thank you for your suggestion. I get excited whenever I get new code in
the hopes that the problem will resolve. Alas, the "Runtime 6028 Error" still
occurs. Any other suggestions?

Dan

"Jay Freedman" wrote:

> Try modifying that line to
>
> mytable.Cell(nrows + 1, 1).Range.Text = TextBox1.Text
>
> Make a similar change to all the other lines that try to assign text
> to a tabl cell.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
>
> On Sun, 16 Sep 2007 15:12:01 -0700, Dan the Man
> <DantheMan(a)discussions.microsoft.com> wrote:
>
> >Don't know if anyone can help me with this or not.
> >
> >I have a Userform on my spreadsheet for inputting "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-Button 3, and Update
> >Comments-Button 4).
> >
> >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.
> >This code exists in my "Word" VB editor. The line of code (for each command
> >button) that highlights in "yellow" (where I suspect is the problem) is:
> >
> >mytable.Cell(nrows + 1, 1) = TextBox1.Text
> >
> >If someone could give me an idea of what I need to look for in order to
> >attack this problem I would appreciate it. 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
>
From: Jay Freedman on
What is the nature of the document, table, and cell at the time the
userform is displayed? Is it "protected" in any way, for forms or
comments, etc.? Is there anything already in the cell?

When I try to use a macro to enter text in a cell in a document that's
protected for forms, I get error 6124, "You are not allowed to edit
this region because document protection is in effect". I'm not sure
what circumstances lead to error 6028 instead. Although a Google
search for that error number turns up several posts, I think they
confuse the issue rather than solving it.

On Sun, 16 Sep 2007 18:26:00 -0700, Dan the Man
<DantheMan(a)discussions.microsoft.com> wrote:

>Jay thank you for your suggestion. I get excited whenever I get new code in
>the hopes that the problem will resolve. Alas, the "Runtime 6028 Error" still
>occurs. Any other suggestions?
>
>Dan
>
>"Jay Freedman" wrote:
>
>> Try modifying that line to
>>
>> mytable.Cell(nrows + 1, 1).Range.Text = TextBox1.Text
>>
>> Make a similar change to all the other lines that try to assign text
>> to a tabl cell.
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
>>
>> On Sun, 16 Sep 2007 15:12:01 -0700, Dan the Man
>> <DantheMan(a)discussions.microsoft.com> wrote:
>>
>> >Don't know if anyone can help me with this or not.
>> >
>> >I have a Userform on my spreadsheet for inputting "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-Button 3, and Update
>> >Comments-Button 4).
>> >
>> >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.
>> >This code exists in my "Word" VB editor. The line of code (for each command
>> >button) that highlights in "yellow" (where I suspect is the problem) is:
>> >
>> >mytable.Cell(nrows + 1, 1) = TextBox1.Text
>> >
>> >If someone could give me an idea of what I need to look for in order to
>> >attack this problem I would appreciate it. 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
>>

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
From: Dan the Man on
Hi Jay:

Again, I'm new to the world of Excel and Word vba coding, so excuse my
neivity. I do not believe that the document, table, or cell at the time the
Userform is displayed is protected in any way. Below is a bit of history
about what was created and how things used to work just fine until we
modified the code. I too "Googled" the applicable Runtime Error before
posting to this group, and did not achieve results either.

I am working with Excel and Word. I have an Excel Spreadsheet, and a Macro
button on that Spreadsheet (entitled Userform Comments) which brings up a
dropdown list of names. When a name is chosen, Excel calls Word, and brings
up my Userform (which works off of Word and not Excel).

Originally I had to create the Word Documents separately in order for the
Userform to work. The modified code is great, because it "automatically"
searches to see if the Word Document already exists, and if it does not, Word
creates it. This saves me the step of creating the Word Document on my own.
So if I have a name on my Excel spreadsheet entitled: Harry Potter, the code
will create a Word Document entitled "PotterHarry.doc" (Column A of my
spreadsheet is last name, and Column B is first name). If I already have a
document created, Word and the Userform will merely open.

I also have 2 separate Excel Worksheets (within my workbook) which contain
some identical names (a worksheet containing OLD Client names and one
containing NEW Client names). The modified code attaches "_old" to a name
existing on the "OLD" spreadsheet that is duplicated on the "NEW" one (e.g.
PotterHarry.doc vs. PotterHarry_Old.doc). This way Word can create the
appropriate document, and not accidentally overwrite one for the other when a
name exists on both spreadsheets.

The odd thing is this. The original version of the spreadsheet and Word
based Userform (where I had to create the Word Documents myself) worked
PERFECTLY. When we modified the code to allow for automatic creation of Word
documents however, the runtime error 6028 was triggered. Previous to this,
all function buttons worked just fine. The other ironic thing is this: "the
code for the Userform-where the function buttons work off of) has NOT
changed.

Code alterations were made to Excel:

Userform 3-which references the dropdown list of names on my Excel
Spreadsheet, allowing me to chose a name from a dropdown list and open the
Word based Userform.

Module 2-the code which creates the individual Word Documents for inputing
comments (using the Userform).

Code alterations were made to Word:

Module 1 "Normal"-which interacts with Excel, allowing the Userform to be
called up (again I'm a noobie so I'm not 100% as to how this code interacts
however I believe it is designed to check Word to see if a Word document has
previously been created for a particular person, or needs to be created).

The code which impacts the actual Userform interface (Userform 1) for
inputting comments has NOT changed, and thus I am perplexed as to why I am
getting the Runtime 6028 error here (the debugger only highlights the code
associated with this Userform that I previously mentioned and posted a copy
of).

Dan



"Jay Freedman" wrote:

> What is the nature of the document, table, and cell at the time the
> userform is displayed? Is it "protected" in any way, for forms or
> comments, etc.? Is there anything already in the cell?
>
> When I try to use a macro to enter text in a cell in a document that's
> protected for forms, I get error 6124, "You are not allowed to edit
> this region because document protection is in effect". I'm not sure
> what circumstances lead to error 6028 instead. Although a Google
> search for that error number turns up several posts, I think they
> confuse the issue rather than solving it.
>
> On Sun, 16 Sep 2007 18:26:00 -0700, Dan the Man
> <DantheMan(a)discussions.microsoft.com> wrote:
>
> >Jay thank you for your suggestion. I get excited whenever I get new code in
> >the hopes that the problem will resolve. Alas, the "Runtime 6028 Error" still
> >occurs. Any other suggestions?
> >
> >Dan
> >
> >"Jay Freedman" wrote:
> >
> >> Try modifying that line to
> >>
> >> mytable.Cell(nrows + 1, 1).Range.Text = TextBox1.Text
> >>
> >> Make a similar change to all the other lines that try to assign text
> >> to a tabl cell.
> >>
> >> --
> >> Regards,
> >> Jay Freedman
> >> Microsoft Word MVP FAQ: http://word.mvps.org
> >> Email cannot be acknowledged; please post all follow-ups to the
> >> newsgroup so all may benefit.
> >>
> >> On Sun, 16 Sep 2007 15:12:01 -0700, Dan the Man
> >> <DantheMan(a)discussions.microsoft.com> wrote:
> >>
> >> >Don't know if anyone can help me with this or not.
> >> >
> >> >I have a Userform on my spreadsheet for inputting "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-Button 3, and Update
> >> >Comments-Button 4).
> >> >
> >> >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.
> >> >This code exists in my "Word" VB editor. The line of code (for each command
> >> >button) that highlights in "yellow" (where I suspect is the problem) is:
> >> >
> >> >mytable.Cell(nrows + 1, 1) = TextBox1.Text
> >> >
> >> >If someone could give me an idea of what I need to look for in order to
> >> >attack this problem I would appreciate it. 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
> >>
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
>