0

Can anyone tell me why i am getting The requestedmember of the
Collection Does not exist.Runtime error '5941'.Any help would be
Greately appreciated.Cursor go on the bold line.

Sub CreateMaterialsTable()
ActiveDocument.Tables.Add Range:=Selection.Range, Numrows:=3, NumColumns:= _
4, defaulttablebehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
ActiveDocument.Tables(3).Select
'selection is Application.selection object
With ActiveDocument.Tables(3)
If .Style <> "tabellengitternetz" Then
   .Style = "Tabellengitternetz"
End If
 .ApplyStyleHeadingRows = True
 .ApplyStyleLastRow = True
 .ApplyStyleFirstColumn = True
 .ApplyStyleLastColumn = True
End With
ActiveDocument.Tables(3).Rows.HeightRule = wdRowHeightExactly
ActiveDocument.Tables(3).Rows.Height = CentimetersToPoints(0.7)
ActiveDocument.Tables(3).Columns(1).PreferredWidthType = wdPreferredWidthPercent
ActiveDocument.Tables(3).Columns(1).PreferredWidth = 8
ActiveDocument.Tables(3).Columns(2).PreferredWidthType = wdPreferredWidthPercent
ActiveDocument.Tables(3).Columns(2).PreferredWidth = 68
ActiveDocument.Tables(3).Columns(3).PreferredWidthType = wdPreferredWidthPercent
ActiveDocument.Tables(3).Columns(3).PreferredWidth = 12
ActiveDocument.Tables(3).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.Font.Size = 8
Selection.Font.Name = "Arial"
CreateHeader
End Sub
2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by cguan_77
0

try this

ActiveDocument.Tables(3).Columns(3).Select

I am Getting same error.Here is the code what i have written.

Sub CreateMaterialsTable()
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=3, NumColumns:= _
4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
'ActiveDocument.Tables(3).Select
ActiveDocument.Tables(3).Columns(3).Select
'selection is Application.selection object
With ActiveDocument.Tables(3)
If .Style <> "tabellengitternetz" Then
   .Style = "Tabellengitternetz"
End If
 .ApplyStyleHeadingRows = True
 .ApplyStyleLastRow = True
 .ApplyStyleFirstColumn = True
 .ApplyStyleLastColumn = True
End With
ActiveDocument.Tables(3).Rows.HeightRule = wdRowHeightExactly
ActiveDocument.Tables(3).Rows.Height = CentimetersToPoints(0.7)
ActiveDocument.Tables(3).Columns(1).PreferredWidthType = wdPreferredWidthPercent
ActiveDocument.Tables(3).Columns(1).PreferredWidth = 8
ActiveDocument.Tables(3).Columns(2).PreferredWidthType = wdPreferredWidthPercent
ActiveDocument.Tables(3).Columns(2).PreferredWidth = 68
ActiveDocument.Tables(3).Columns(3).PreferredWidthType = wdPreferredWidthPercent
ActiveDocument.Tables(3).Columns(3).PreferredWidth = 12
ActiveDocument.Tables(3).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.Font.Size = 8
Selection.Font.Name = "Arial"
CreateHeader
Call AddMaterialLine(1, "AMERON QA 308 ZINC PHOSPHATA PRIMAR OD GREY", "LITERS", "100")
Call AddMaterialLine(2, "AMERON QA 304 ZINC PHOSPHATA PRIMAR OD RED", "LITERS", "100")
ActiveDocument.Paragraphs.Last.Range.Select
End Sub
0

hi firoz.raj make sure that you have three different tables.. what i mean you should have like table1 then table2 then table3.
ex.
table1 with 3 rows and 4 columns
space
table2 with 3 rows and 4 columns
space
table3 with 3 rows and 4 columns

0

hi firoz.raj make sure that you have three different tables.. what i mean you should have like table1 then table2 then table3.
ex.
still getting error the requested member of the collection does not
exist.here is the code what i have written.

Sub CreateMaterialsTable()
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=3, NumColumns:= _
4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
'ActiveDocument.Tables(3).Select
[B]ActiveDocument.Tables(3).Columns(3).Select[/B]
'selection is Application.selection object
With ActiveDocument.Tables(3)
If .Style <> "Table Grid" Then
   .Style = "Table Grid"
End If
 .ApplyStyleHeadingRows = True
 .ApplyStyleLastRow = True
 .ApplyStyleFirstColumn = True
 .ApplyStyleLastColumn = True
End With
ActiveDocument.Tables(3).Rows.HeightRule = wdRowHeightExactly
ActiveDocument.Tables(3).Rows.Height = CentimetersToPoints(0.7)
ActiveDocument.Tables(3).Columns(1).PreferredWidthType = wdPreferredWidthPercent
ActiveDocument.Tables(3).Columns(1).PreferredWidth = 8
ActiveDocument.Tables(3).Columns(2).PreferredWidthType = wdPreferredWidthPercent
ActiveDocument.Tables(3).Columns(2).PreferredWidth = 68
ActiveDocument.Tables(3).Columns(3).PreferredWidthType = wdPreferredWidthPercent
ActiveDocument.Tables(3).Columns(3).PreferredWidth = 12
ActiveDocument.Tables(3).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.Font.Size = 8
Selection.Font.Name = "Arial"
CreateHeader
Call AddMaterialLine(1, "AMERON QA 308 ZINC PHOSPHATA PRIMAR OD GREY", "LITERS", "100")
Call AddMaterialLine(2, "AMERON QA 304 ZINC PHOSPHATA PRIMAR OD RED", "LITERS", "100")
ActiveDocument.Paragraphs.Last.Range.Select
End Sub
0

hi, forget to tell you use you original code...try this out.. hope it works.. :)

ActiveDocument.Tables(3).Select
'ActiveDocument.Tables(3).Columns(3).Select (remove this one)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.