From: Jack on 5 Jan 2007 20:42 I have 5 tables all the same size 5 rows by 7 columns. I have another separate table called tblSub that I want to insert into any two empty cells of each of the 5 main tables . My code is as follows: ********** Set tblSub = ActiveDocument.Tables(6) tblSub.Select Selection.Copy For it = 1 To 5 iSubCount = 0 For Each oCell In ActiveDocument.Tables(it).Range.Cells If oCell.Range.Text = Chr(13) & Chr(7) Then 'Cell is empty, store subtable iSubCount = iSubCount + 1 oCell.Range.PasteAsNestedTable If iSubCount = 2 Then Exit For End If Next oCell Next it ********* This code works correctly for 3 inserts. When it=2 and isubcount=2, I get the run time error 4605 "The command is not available" The command "pasteasnestedtable" is the culprit. Each table does have at least two empty cells. Any suggestions? Jack
From: Klaus Linke on 6 Jan 2007 02:35 Hi Jack, Works without error for me... Maybe you could stick in an oCell.Range.Select (or run that in the immediate window when the macro errors out), to see the problematic cell? Is there some possible complication, say "Track changes" turned on? The table could be damaged. Maybe convert the second table to text, and back to table. Regards, Klaus "Jack" <wittenews(a)comcast.net> schrieb im Newsbeitrag news:KqudnffrTMUNYwPYnZ2dnUVZ_uqvnZ2d(a)comcast.com... >I have 5 tables all the same size 5 rows by 7 columns. I have another >separate table called tblSub that I want to insert into any two empty cells >of each of the 5 main tables . > My code is as follows: > ********** > Set tblSub = ActiveDocument.Tables(6) > tblSub.Select > Selection.Copy > For it = 1 To 5 > iSubCount = 0 > For Each oCell In ActiveDocument.Tables(it).Range.Cells > If oCell.Range.Text = Chr(13) & Chr(7) Then > 'Cell is empty, store subtable > iSubCount = iSubCount + 1 > oCell.Range.PasteAsNestedTable > If iSubCount = 2 Then Exit For > End If > Next oCell > Next it > ********* > This code works correctly for 3 inserts. When it=2 and isubcount=2, I get > the run time error 4605 "The command is not available" > The command "pasteasnestedtable" is the culprit. > Each table does have at least two empty cells. > Any suggestions? > Jack >
From: Jack on 6 Jan 2007 15:28 I did as you suggested-ocell.range.select but it made no difference. I have deleted the second table and created another just for test and the same thing happens. I not sure of track changes. I checked document.trackrevisions and it is false. When it does halt at the error, I can go back to the document and see that under the edit command, that all the paste commands are greyed out. So why this happens is still a mystery Jack "Klaus Linke" <info(a)fotosatz-kaufmann.de> wrote in message news:uOsj$UWMHHA.3556(a)TK2MSFTNGP03.phx.gbl... > Hi Jack, > > Works without error for me... > > Maybe you could stick in an > oCell.Range.Select > (or run that in the immediate window when the macro errors out), to see > the problematic cell? > > Is there some possible complication, say "Track changes" turned on? > > The table could be damaged. Maybe convert the second table to text, and > back to table. > > Regards, > Klaus > > > "Jack" <wittenews(a)comcast.net> schrieb im Newsbeitrag > news:KqudnffrTMUNYwPYnZ2dnUVZ_uqvnZ2d(a)comcast.com... >>I have 5 tables all the same size 5 rows by 7 columns. I have another >>separate table called tblSub that I want to insert into any two empty >>cells of each of the 5 main tables . >> My code is as follows: >> ********** >> Set tblSub = ActiveDocument.Tables(6) >> tblSub.Select >> Selection.Copy >> For it = 1 To 5 >> iSubCount = 0 >> For Each oCell In ActiveDocument.Tables(it).Range.Cells >> If oCell.Range.Text = Chr(13) & Chr(7) Then >> 'Cell is empty, store subtable >> iSubCount = iSubCount + 1 >> oCell.Range.PasteAsNestedTable >> If iSubCount = 2 Then Exit For >> End If >> Next oCell >> Next it >> ********* >> This code works correctly for 3 inserts. When it=2 and isubcount=2, I >> get the run time error 4605 "The command is not available" >> The command "pasteasnestedtable" is the culprit. >> Each table does have at least two empty cells. >> Any suggestions? >> Jack >> > >
From: Klaus Linke on 6 Jan 2007 15:52 In Word2003/2007, the cell could be protected. But since it happens with a newly created table too, that seems out of the question. I'd have offered that you mail me the document, but if it happens with a new table, it probably also happens with a new document? I'm fresh out of ideas, and hope somebody else will jump in. :-( Klaus "Jack" <wittenews(a)comcast.net> wrote: >I did as you suggested-ocell.range.select but it made no difference. I >have deleted the second table and created another just for test and the >same thing happens. I not sure of track changes. I checked >document.trackrevisions and it is false. > When it does halt at the error, I can go back to the document and see that > under the edit command, that all the paste commands are greyed out. So > why this happens is still a mystery > Jack > > "Klaus Linke" <info(a)fotosatz-kaufmann.de> wrote in message > news:uOsj$UWMHHA.3556(a)TK2MSFTNGP03.phx.gbl... >> Hi Jack, >> >> Works without error for me... >> >> Maybe you could stick in an >> oCell.Range.Select >> (or run that in the immediate window when the macro errors out), to see >> the problematic cell? >> >> Is there some possible complication, say "Track changes" turned on? >> >> The table could be damaged. Maybe convert the second table to text, and >> back to table. >> >> Regards, >> Klaus >> >> >> "Jack" <wittenews(a)comcast.net> schrieb im Newsbeitrag >> news:KqudnffrTMUNYwPYnZ2dnUVZ_uqvnZ2d(a)comcast.com... >>>I have 5 tables all the same size 5 rows by 7 columns. I have another >>>separate table called tblSub that I want to insert into any two empty >>>cells of each of the 5 main tables . >>> My code is as follows: >>> ********** >>> Set tblSub = ActiveDocument.Tables(6) >>> tblSub.Select >>> Selection.Copy >>> For it = 1 To 5 >>> iSubCount = 0 >>> For Each oCell In ActiveDocument.Tables(it).Range.Cells >>> If oCell.Range.Text = Chr(13) & Chr(7) Then >>> 'Cell is empty, store subtable >>> iSubCount = iSubCount + 1 >>> oCell.Range.PasteAsNestedTable >>> If iSubCount = 2 Then Exit For >>> End If >>> Next oCell >>> Next it >>> ********* >>> This code works correctly for 3 inserts. When it=2 and isubcount=2, I >>> get the run time error 4605 "The command is not available" >>> The command "pasteasnestedtable" is the culprit. >>> Each table does have at least two empty cells. >>> Any suggestions? >>> Jack >>> >> >> > >
From: Jack on 7 Jan 2007 20:13 I never got my original code to work but I did change to the following code and it works correctly. It is still a puzzle to me while the original code did not work Jack New Code: ActiveDocument.Tables(6).select Selection.Copy For it = 1 To 5 iSubCount = 0 ActiveDocument.Tables(it).Range.Cells(1).range.select do while isubcount<2 IF selection.Text = Chr(13) & Chr(7) Then 'Cell is empty, store subtable iSubCount = iSubCount + 1 selection.pasteAsNestedTable End If selection.moveright unit:=wdcell loop next it "Klaus Linke" <info(a)fotosatz-kaufmann.de> wrote in message news:u9kIWSdMHHA.3556(a)TK2MSFTNGP03.phx.gbl... > In Word2003/2007, the cell could be protected. But since it happens with a > newly created table too, that seems out of the question. > I'd have offered that you mail me the document, but if it happens with a > new table, it probably also happens with a new document? > > I'm fresh out of ideas, and hope somebody else will jump in. > > :-( Klaus > > > > > "Jack" <wittenews(a)comcast.net> wrote: >>I did as you suggested-ocell.range.select but it made no difference. I >>have deleted the second table and created another just for test and the >>same thing happens. I not sure of track changes. I checked >>document.trackrevisions and it is false. >> When it does halt at the error, I can go back to the document and see >> that under the edit command, that all the paste commands are greyed out. >> So why this happens is still a mystery >> Jack >> >> "Klaus Linke" <info(a)fotosatz-kaufmann.de> wrote in message >> news:uOsj$UWMHHA.3556(a)TK2MSFTNGP03.phx.gbl... >>> Hi Jack, >>> >>> Works without error for me... >>> >>> Maybe you could stick in an >>> oCell.Range.Select >>> (or run that in the immediate window when the macro errors out), to see >>> the problematic cell? >>> >>> Is there some possible complication, say "Track changes" turned on? >>> >>> The table could be damaged. Maybe convert the second table to text, and >>> back to table. >>> >>> Regards, >>> Klaus >>> >>> >>> "Jack" <wittenews(a)comcast.net> schrieb im Newsbeitrag >>> news:KqudnffrTMUNYwPYnZ2dnUVZ_uqvnZ2d(a)comcast.com... >>>>I have 5 tables all the same size 5 rows by 7 columns. I have another >>>>separate table called tblSub that I want to insert into any two empty >>>>cells of each of the 5 main tables . >>>> My code is as follows: >>>> ********** >>>> Set tblSub = ActiveDocument.Tables(6) >>>> tblSub.Select >>>> Selection.Copy >>>> For it = 1 To 5 >>>> iSubCount = 0 >>>> For Each oCell In ActiveDocument.Tables(it).Range.Cells >>>> If oCell.Range.Text = Chr(13) & Chr(7) Then >>>> 'Cell is empty, store subtable >>>> iSubCount = iSubCount + 1 >>>> oCell.Range.PasteAsNestedTable >>>> If iSubCount = 2 Then Exit For >>>> End If >>>> Next oCell >>>> Next it >>>> ********* >>>> This code works correctly for 3 inserts. When it=2 and isubcount=2, I >>>> get the run time error 4605 "The command is not available" >>>> The command "pasteasnestedtable" is the culprit. >>>> Each table does have at least two empty cells. >>>> Any suggestions? >>>> Jack >>>> >>> >>> >> >> > >
|
Pages: 1 Prev: Can't exit design mode Next: Word 2007 backward compatibility - RoutingSlips |