Error in CreatematerilsTable

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2008
Posts: 304
Reputation: firoz.raj is an unknown quantity at this point 
Solved Threads: 1
firoz.raj firoz.raj is offline Offline
Posting Whiz

Error in CreatematerilsTable

 
0
  #1
May 10th, 2009
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
Last edited by firoz.raj; May 10th, 2009 at 8:59 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,126
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 93
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: Error in CreatematerilsTable

 
0
  #2
May 11th, 2009
try this

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ActiveDocument.Tables(3).Columns(3).Select
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 304
Reputation: firoz.raj is an unknown quantity at this point 
Solved Threads: 1
firoz.raj firoz.raj is offline Offline
Posting Whiz

Re: Error in CreatematerilsTable

 
0
  #3
May 11th, 2009
Originally Posted by cguan_77 View Post
try this

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 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
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,126
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 93
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: Error in CreatematerilsTable

 
0
  #4
May 11th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 304
Reputation: firoz.raj is an unknown quantity at this point 
Solved Threads: 1
firoz.raj firoz.raj is offline Offline
Posting Whiz

Re: Error in CreatematerilsTable

 
0
  #5
May 12th, 2009
[QUOTE=cguan_77;867090]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
ActiveDocument.Tables(3).Columns(3).Select
'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
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,126
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 93
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: Error in CreatematerilsTable

 
0
  #6
May 12th, 2009
hi, forget to tell you use you original code...try this out.. hope it works..

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ActiveDocument.Tables(3).Select
  2. 'ActiveDocument.Tables(3).Columns(3).Select (remove this one)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 665 | Replies: 5
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC