私は長い間、初めてVBAで作業しており、ドキュメントをテーブルに追加する際に助けが必要です。現時点ではドキュメントへのテーブルの追加エラー - オブジェクト変数またはブロック変数が設定されていません
問題の行が
.Cell(1, x).Range.Select
であると私は取得エラーがオブジェクト変数またはブロック変数が設定されていないとされます。私の人生の間、私はこの場所でどこが間違っているのか分かりません。
私はテーブルに渡すために探しています3次元の文字列配列を渡していますし、これは、誰かがこれを確認することができれば、私は感謝される私は一瞬
Private Sub Create_Sized_Table_Multi_Column(i_Rows As Integer, i_Columns As Integer)
'create a table
Set t_newtable = ActiveDocument.Tables.Add(Selection.Range, i_Rows, i_Columns)
End Sub
Private Sub BuildTable(arr() As String, colCount As Integer, bookMark As String)
Dim t_newtable As Table
Dim i_Fund_Quantity As Integer
Dim i_Rows_Required As Integer
Dim i_Columns_Required As Integer
'Number of funds is the upperbound + 1 to allow for the zero relative
i_Fund_Quantity = UBound(arr) + 1
'header Row
i_Rows_Required = UBound(arr) + 1
'Number of columns
i_Columns_Required = colCount
'Add a table - this table will contain moved funds
'creates the table dimensioned by i_rows x i_column
Create_Sized_Table_Multi_Column i_Rows_Required, i_Columns_Required
'Now populate the header row
With t_newtable
For x = 0 To i_Columns_Required
.Cell(1, x).Range.Select
If x = 1 Then
Set_Table_Headers "Existing Fund"
ElseIf x = 2 Then
Set_Table_Headers "Customer Name"
ElseIf x = 3 Then
Set_Table_Headers "Switch To"
ActiveDocument.Bookmarks.Add ("bk_Switched_Table")
End If
Next
End With
'Populate the table with the fund details
''//sp write to table here
With t_newtable
'Position cursor at first insertion point
'ActiveDocument.Bookmarks("bk_Switched_Table").Select
'Now create a loop
For i_Loop_Rows = 0 To UBound(arr)
Set_Table_Rows
Selection.TypeText arr(i, 0)
Selection.MoveRight UNIT:=wdCell
Selection.TypeText arr(i, 1)
Selection.MoveRight UNIT:=wdCell
Selection.TypeText arr(i, 2)
t_newtable.Columns(3).Select
t_newtable.Columns.AutoFit
Selection.Collapse Direction:=wdCollapseEnd
Next
End With
ActiveDocument.Bookmarks(bookMark).Select
Selection.TypeParagraph
Selection.TypeText s_Text
Selection.TypeParagraph
ActiveDocument.Bookmarks.Add (bookMark)
End Sub
にして働いていたコードです私がどこに間違っていて、どこを変える必要があるかを教えてください。あなたのBuildTable
サブにt_newtable
を設定することはありません
おかげ
サイモン
ありがとうございます!私が言っているようにVBAを使用してからしばらくしていて、家に生まれたばかりの新しいものを持っています... –
はい、非常に気を散らす:-) –