Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.vba.beginners,microsoft.public.word.vba.userforms,microsoft.public.word.tables
|
|||
|
|||
![]()
Hello everyone. I am using Microsoft Office 2007 and I have created a
form that pulls information from an Access database and puts it in a table. I want to have 3 tables per page that are populated with information from the database. My dilemma is I can populate one table, but for some reason the table will not repeat for the next recordset. I get runtime error '4605': this method or property is not availavel because the object refers to the end of a table row. The following line of code is what is highlighted. ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed Here is a copy of my code. rs.MoveFirst If Not rs.EOF Then Do Until rs.EOF Opinion.txtAppellant = rs.Fields("Appellant").Value & " " Opinion.txtAppellee = rs.Fields("Appellee").Value & " " Opinion.txtCaseNumber = rs.Fields("CaseNo").Value & " " Opinion.txtOpinionDate = rs.Fields("Opinion_Date").Value & " " '*****Hide the form so the document can come up***** Opinion.Hide '****Insert table***** ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed With Selection.Tables(1) If .Style "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True End With Selection.Tables(1).Rows.HeightRule = wdRowHeightAtLeast Selection.Tables(1).Rows.Height = InchesToPoints(0.3) Selection.Tables(1).Range.Font.AllCaps = True Selection.Tables(1).Range.Font.Size = 14 Selection.Tables(1).Range.Font.Name = "Times New Roman" Selection.Range.Cells(1).VerticalAlignment = wdCellAlignVerticalTop With Selection.Tables(1) .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .Borders(wdBorderTop).LineStyle = wdLineStyleNone .Borders(wdBorderBottom).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone .Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle .Borders.Shadow = False End With '*****Add the formatting for the document***** With Selection .ParagraphFormat.LineSpacingRule = wdLineSpaceSingle .ParagraphFormat.Alignment = wdAlignParagraphLeft .SelectRow .Cells.Merge .TypeText Text:="case of " & txtAppellant.Value .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="vs. " & txtAppellee.Value .MoveDown Unit:=wdLine, Count:=1 .TypeText Text:="docket no. " & txtCaseNumber.Value .MoveRight Unit:=wdCell .TypeText Text:="Opinion Filed " & txtOpinionDate.Value .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing petition filed" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing denied" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing granted" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="released for publication" .MoveDown Unit:=wdLine, Count:=1 .TypeText Text:="date" .MoveRight Unit:=wdCell .TypeText Text:="Signed" rs.MoveNext End With Loop End If Thanks in advance for your assistance. |
#2
![]()
Posted to microsoft.public.word.vba.beginners,microsoft.public.word.vba.userforms,microsoft.public.word.tables
|
|||
|
|||
![]()
I would suggest that you avoid using the .Selection object and make use of
the .Range object instead. On the assumption that the tables are being added to the end of the document, you should use something like Dim trange as Range Dim ntable as Table rs.MoveFirst If Not rs.EOF Then Do Until rs.EOF Opinion.txtAppellant = rs.Fields("Appellant").Value & " " Opinion.txtAppellee = rs.Fields("Appellee").Value & " " Opinion.txtCaseNumber = rs.Fields("CaseNo").Value & " " Opinion.txtOpinionDate = rs.Fields("Opinion_Date").Value & " " '*****Hide the form so the document can come up***** Opinion.Hide '****Insert table***** Set trange = ActiveDocument.Range trange.Collapse wdCollapseEnd Set ntable = ActiveDocument.Tables.Add Range:=trange, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed With ntable If .Style "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True .Rows.HeightRule = wdRowHeightAtLeast .Rows.Height = InchesToPoints(0.3) .Range.Font.AllCaps = True .Range.Font.Size = 14 .Range.Font.Name = "Times New Roman" .Cells(1).VerticalAlignment = wdCellAlignVerticalTop 'I don't know where the selection is at this point; you must specify the row and column number etd -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "trezraven" wrote in message oups.com... Hello everyone. I am using Microsoft Office 2007 and I have created a form that pulls information from an Access database and puts it in a table. I want to have 3 tables per page that are populated with information from the database. My dilemma is I can populate one table, but for some reason the table will not repeat for the next recordset. I get runtime error '4605': this method or property is not availavel because the object refers to the end of a table row. The following line of code is what is highlighted. ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed Here is a copy of my code. rs.MoveFirst If Not rs.EOF Then Do Until rs.EOF Opinion.txtAppellant = rs.Fields("Appellant").Value & " " Opinion.txtAppellee = rs.Fields("Appellee").Value & " " Opinion.txtCaseNumber = rs.Fields("CaseNo").Value & " " Opinion.txtOpinionDate = rs.Fields("Opinion_Date").Value & " " '*****Hide the form so the document can come up***** Opinion.Hide '****Insert table***** ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed With Selection.Tables(1) If .Style "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True End With Selection.Tables(1).Rows.HeightRule = wdRowHeightAtLeast Selection.Tables(1).Rows.Height = InchesToPoints(0.3) Selection.Tables(1).Range.Font.AllCaps = True Selection.Tables(1).Range.Font.Size = 14 Selection.Tables(1).Range.Font.Name = "Times New Roman" Selection.Range.Cells(1).VerticalAlignment = wdCellAlignVerticalTop With Selection.Tables(1) .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .Borders(wdBorderTop).LineStyle = wdLineStyleNone .Borders(wdBorderBottom).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone .Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle .Borders.Shadow = False End With '*****Add the formatting for the document***** With Selection .ParagraphFormat.LineSpacingRule = wdLineSpaceSingle .ParagraphFormat.Alignment = wdAlignParagraphLeft .SelectRow .Cells.Merge .TypeText Text:="case of " & txtAppellant.Value .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="vs. " & txtAppellee.Value .MoveDown Unit:=wdLine, Count:=1 .TypeText Text:="docket no. " & txtCaseNumber.Value .MoveRight Unit:=wdCell .TypeText Text:="Opinion Filed " & txtOpinionDate.Value .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing petition filed" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing denied" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing granted" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="released for publication" .MoveDown Unit:=wdLine, Count:=1 .TypeText Text:="date" .MoveRight Unit:=wdCell .TypeText Text:="Signed" rs.MoveNext End With Loop End If Thanks in advance for your assistance. |
#3
![]()
Posted to microsoft.public.word.vba.beginners,microsoft.public.word.vba.userforms,microsoft.public.word.tables
|
|||
|
|||
![]()
On Feb 2, 1:15 pm, "Doug Robbins - Word MVP"
wrote: I would suggest that you avoid using the .Selection object and make use of the .Range object instead. On the assumption that the tables are being added to the end of the document, you should use something like Dim trange as Range Dim ntable as Table rs.MoveFirst If Not rs.EOF Then Do Until rs.EOF Opinion.txtAppellant = rs.Fields("Appellant").Value & " " Opinion.txtAppellee = rs.Fields("Appellee").Value & " " Opinion.txtCaseNumber = rs.Fields("CaseNo").Value & " " Opinion.txtOpinionDate = rs.Fields("Opinion_Date").Value & " " '*****Hide the form so the document can come up***** Opinion.Hide '****Insert table***** Set trange = ActiveDocument.Range trange.Collapse wdCollapseEnd Set ntable = ActiveDocument.Tables.Add Range:=trange, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed With ntable If .Style "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True .Rows.HeightRule = wdRowHeightAtLeast .Rows.Height = InchesToPoints(0.3) .Range.Font.AllCaps = True .Range.Font.Size = 14 .Range.Font.Name = "Times New Roman" .Cells(1).VerticalAlignment = wdCellAlignVerticalTop 'I don't know where the selection is at this point; you must specify the row and column number etd -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "trezraven" wrote in message oups.com... Hello everyone. I am using Microsoft Office 2007 and I have created a form that pulls information from an Access database and puts it in a table. I want to have 3 tables per page that are populated with information from the database. My dilemma is I can populate one table, but for some reason the table will not repeat for the next recordset. I get runtime error '4605': this method or property is not availavel because the object refers to the end of a table row. The following line of code is what is highlighted. ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed Here is a copy of my code. rs.MoveFirst If Not rs.EOF Then Do Until rs.EOF Opinion.txtAppellant = rs.Fields("Appellant").Value & " " Opinion.txtAppellee = rs.Fields("Appellee").Value & " " Opinion.txtCaseNumber = rs.Fields("CaseNo").Value & " " Opinion.txtOpinionDate = rs.Fields("Opinion_Date").Value & " " '*****Hide the form so the document can come up***** Opinion.Hide '****Insert table***** ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed With Selection.Tables(1) If .Style "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True End With Selection.Tables(1).Rows.HeightRule = wdRowHeightAtLeast Selection.Tables(1).Rows.Height = InchesToPoints(0.3) Selection.Tables(1).Range.Font.AllCaps = True Selection.Tables(1).Range.Font.Size = 14 Selection.Tables(1).Range.Font.Name = "Times New Roman" Selection.Range.Cells(1).VerticalAlignment = wdCellAlignVerticalTop With Selection.Tables(1) .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .Borders(wdBorderTop).LineStyle = wdLineStyleNone .Borders(wdBorderBottom).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone .Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle .Borders.Shadow = False End With '*****Add the formatting for the document***** With Selection .ParagraphFormat.LineSpacingRule = wdLineSpaceSingle .ParagraphFormat.Alignment = wdAlignParagraphLeft .SelectRow .Cells.Merge .TypeText Text:="case of " & txtAppellant.Value .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="vs. " & txtAppellee.Value .MoveDown Unit:=wdLine, Count:=1 .TypeText Text:="docket no. " & txtCaseNumber.Value .MoveRight Unit:=wdCell .TypeText Text:="Opinion Filed " & txtOpinionDate.Value .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing petition filed" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing denied" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing granted" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="released for publication" .MoveDown Unit:=wdLine, Count:=1 .TypeText Text:="date" .MoveRight Unit:=wdCell .TypeText Text:="Signed" rs.MoveNext End With Loop End If Thanks in advance for your assistance.- Hide quoted text - - Show quoted text - I made the changes you suggested and now I am getting Compile Error: expected end of statement. Range is highlighted on the Set ntable line of code. Dim trange As Range Dim ntable As Table Set trange = ActiveDocument.Range trange.Collapse wdCollapseEnd Set ntable = ActiveDocument.Tables.Add Range:=trange, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed |
#4
![]()
Posted to microsoft.public.word.tables,microsoft.public.word.vba.beginners,microsoft.public.word.vba.userforms
|
|||
|
|||
![]()
On Feb 2, 2:23 pm, "trezraven" wrote:
On Feb 2, 1:15 pm, "Doug Robbins - Word MVP" wrote: I would suggest that you avoid using the .Selection object and make use of the .Range object instead. On the assumption that the tables are being added to the end of the document, you should use something like Dim trange as Range Dim ntable as Table rs.MoveFirst If Not rs.EOF Then Do Until rs.EOF Opinion.txtAppellant = rs.Fields("Appellant").Value & " " Opinion.txtAppellee = rs.Fields("Appellee").Value & " " Opinion.txtCaseNumber = rs.Fields("CaseNo").Value & " " Opinion.txtOpinionDate = rs.Fields("Opinion_Date").Value & " " '*****Hide the form so the document can come up***** Opinion.Hide '****Insert table***** Set trange = ActiveDocument.Range trange.Collapse wdCollapseEnd Set ntable = ActiveDocument.Tables.Add Range:=trange, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed With ntable If .Style "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True .Rows.HeightRule = wdRowHeightAtLeast .Rows.Height = InchesToPoints(0.3) .Range.Font.AllCaps = True .Range.Font.Size = 14 .Range.Font.Name = "Times New Roman" .Cells(1).VerticalAlignment = wdCellAlignVerticalTop 'I don't know where the selection is at this point; you must specify the row and column number etd -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "trezraven" wrote in message roups.com... Hello everyone. I am using Microsoft Office 2007 and I have created a form that pulls information from an Access database and puts it in a table. I want to have 3 tables per page that are populated with information from the database. My dilemma is I can populate one table, but for some reason the table will not repeat for the next recordset. I get runtime error '4605': this method or property is not availavel because the object refers to the end of a table row. The following line of code is what is highlighted. ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed Here is a copy of my code. rs.MoveFirst If Not rs.EOF Then Do Until rs.EOF Opinion.txtAppellant = rs.Fields("Appellant").Value & " " Opinion.txtAppellee = rs.Fields("Appellee").Value & " " Opinion.txtCaseNumber = rs.Fields("CaseNo").Value & " " Opinion.txtOpinionDate = rs.Fields("Opinion_Date").Value & " " '*****Hide the form so the document can come up***** Opinion.Hide '****Insert table***** ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed With Selection.Tables(1) If .Style "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True End With Selection.Tables(1).Rows.HeightRule = wdRowHeightAtLeast Selection.Tables(1).Rows.Height = InchesToPoints(0.3) Selection.Tables(1).Range.Font.AllCaps = True Selection.Tables(1).Range.Font.Size = 14 Selection.Tables(1).Range.Font.Name = "Times New Roman" Selection.Range.Cells(1).VerticalAlignment = wdCellAlignVerticalTop With Selection.Tables(1) .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .Borders(wdBorderTop).LineStyle = wdLineStyleNone .Borders(wdBorderBottom).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone .Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle .Borders.Shadow = False End With '*****Add the formatting for the document***** With Selection .ParagraphFormat.LineSpacingRule = wdLineSpaceSingle .ParagraphFormat.Alignment = wdAlignParagraphLeft .SelectRow .Cells.Merge .TypeText Text:="case of " & txtAppellant.Value .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="vs. " & txtAppellee.Value .MoveDown Unit:=wdLine, Count:=1 .TypeText Text:="docket no. " & txtCaseNumber.Value .MoveRight Unit:=wdCell .TypeText Text:="Opinion Filed " & txtOpinionDate.Value .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing petition filed" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing denied" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="rehearing granted" .MoveDown Unit:=wdLine, Count:=1 .SelectRow .Cells.Merge .TypeText Text:="released for publication" .MoveDown Unit:=wdLine, Count:=1 .TypeText Text:="date" .MoveRight Unit:=wdCell .TypeText Text:="Signed" rs.MoveNext End With Loop End If Thanks in advance for your assistance.- Hide quoted text - - Show quoted text - I made the changes you suggested and now I am getting Compile Error: expected end of statement. Range is highlighted on the Set ntable line of code. Dim trange As Range Dim ntable As Table Set trange = ActiveDocument.Range trange.Collapse wdCollapseEnd Set ntable = ActiveDocument.Tables.Add Range:=trange, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed- Hide quoted text - - Show quoted text - I figured it out. I just had to add parenthesis. Set trange = ActiveDocument.Range trange.Collapse wdCollapseEnd Set ntable = ActiveDocument.Tables.Add(Range:=trange, NumRows:=8, NumColumns:=2, _ DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed) Thanks again!!! |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
page number does not appear | Page Layout | |||
I want to start Page '1' on the 3rd page. HOW???????? HELP????? | Page Layout | |||
Keep lines in a table from repeating across page break | Tables | |||
Want to start page 1 numbering after five pages - how? | Page Layout | |||
My table headers are not repeating at the top of each page | Mailmerge |