Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vb how do you navigate to column mapping for a column

8 views
Skip to first unread message

bill.st...@gmail.com

unread,
Jun 29, 2017, 9:29:48 PM6/29/17
to
I have the following code to create a source to target excel document. I've been trying to figure out how to navigate the object model to get the column mapping properties associated with the column. Thanks in Advance!

Sub %Method%(obj)
'on error resume next
DIM vExcel
' Implement your method on <obj> here
Set vExcel = CreateObject("Excel.Application")
'
dim colmap
dim lineNum
dim Column
vExcel.Visible = True
vExcel.Workbooks.Add

vExcel.Range("A1").Value = "ID" 'Source Column Order

vExcel.Range("B1").Value = "Source Table"
vExcel.Range("C1").Value = "Source Column"
vExcel.Range("D1").Value = "Source Data Type"
vExcel.Range("E1").Value = "Source Key"
vExcel.Range("F1").Value = "Source Nulls Allowed"
vExcel.Range("G1").Value = " "
vExcel.Range("H1").Value = "Sample Data "
vExcel.Range("I1").Value = " "
vExcel.Range("J1").Value = "ID " 'Target Column Order
vExcel.Range("K1").Value = "Target Table"
vExcel.Range("L1").Value = "Target Column"
vExcel.Range("M1").Value = "Target Data Type"
vExcel.Range("N1").Value = "Target Key"
vExcel.Range("O1").Value = "Target Mandatory"
vExcel.Range("P1").Value = " "
vExcel.Range("Q1").Value = "Source Transformation Rules"


lineNum=2
for each column in obj.Columns
'msgbox "Column " + column.table.code



'vExcel.Range("A"+Cstr(lineNum)).Value = CStrObj(colmap.DataSource ) ' source column id
'vExcel.Range("B"+Cstr(lineNum)).Value = colmap.Table ' source Table
'vExcel.Range("C"+Cstr(lineNum)).Value = CStrObj(obj.Column ) 'source column
'vExcel.Range("D"+Cstr(lineNum)).Value = "" 'source data type
'vExcel.Range("E"+Cstr(lineNum)).Value = "" ' source key
'vExcel.Range("F"+Cstr(lineNum)).Value = "" 'source Nulls Allowed
'vExcel.Range("G"+Cstr(lineNum)).Value = ""
'vExcel.Range("H"+Cstr(lineNum)).Value = ""
'Target
vExcel.Range("J"+Cstr(lineNum)).Value = lineNum-1
vExcel.Range("K"+Cstr(lineNum)).Value = column.table.code
vExcel.Range("L"+Cstr(lineNum)).Value = column.code
vExcel.Range("M"+Cstr(lineNum)).Value = column.DataType
If column.primary Then
vExcel.Range("N"+Cstr(lineNum)).Value = "P"
Else
If column.foreignKey Then
vExcel.Range("N"+Cstr(lineNum)).Value = "F"
Else
vExcel.Range("N"+Cstr(lineNum)).Value = "NA"
End If
End If
If column.mandatory Then
vExcel.Range("O"+Cstr(lineNum)).Value = "N"
Else
vExcel.Range("O"+Cstr(lineNum)).Value = "Y"
End If
lineNum = lineNum + 1
next

vExcel.Columns("A:Q").EntireColumn.AutoFit

End Sub
0 new messages