Sie sind auf Seite 1von 12

Module1 - 1

Dim RamDataAcc1 As RAMDATAACCESSLib.RamDataAccess1 Dim RamDataAccIDBIO As RAMDATAACCESSLib.IDBIO1 Dim IModel As RAMDATAACCESSLib.IModel Dim ISteelCriteria As RAMDATAACCESSLib.ISteelCriteria Dim IModelData1 As RAMDATAACCESSLib.IModelData1 Dim IStories As RAMDATAACCESSLib.IStories Dim IStory As RAMDATAACCESSLib.IStory Dim IBeams As RAMDATAACCESSLib.IBeams Dim IBeam As RAMDATAACCESSLib.IBeam

Dim IColumns As RAMDATAACCESSLib.IColumns Dim IColumn As RAMDATAACCESSLib.IColumn

Dim IHBraces As RAMDATAACCESSLib.IHorizBraces Dim IHBrace As RAMDATAACCESSLib.IHorizBrace

Dim IVBraces As RAMDATAACCESSLib.IVerticalBraces Dim IVBrace As RAMDATAACCESSLib.IVerticalBrace

Dim IReactionNodes As RAMDATAACCESSLib.IReactionNodes Dim IReactionNode As RAMDATAACCESSLib.IReactionNode

Dim IProperties As RAMDATAACCESSLib.IProperties Dim IProperty As RAMDATAACCESSLib.IProperty Dim ISteelBeamDesignResult As RAMDATAACCESSLib.ISteelBeamDesignResult

Dim prop As Props

Dim pStartPoint As RAMDATAACCESSLib.SCoordinate Dim pEndPoint As RAMDATAACCESSLib.SCoordinate Dim dVersion As Double Dim dVMin As Double

'Long Dim R As Long Dim lNumMems As Long Dim lNumStories As Long Dim lStory As Long Dim lMem As Long Dim lNumCants As Long Dim lMemberID As Double Dim plNumStudSegments As Long Dim lSizeOfArrayOfStuds As Long Dim lTotalStuds As Long Dim lStudSeg As Long Dim i As Long Dim lNumPoints As Long Dim lPoint As Long Dim lStoryUID As Long Dim NumFinalPolygons As Long Dim lFinalPolygon As Long Dim NumFinalDiaphragms As Long Dim lHole As Long Dim lFirstSpace As Long Dim j As Long Dim lNumWebOpenings As Long Dim lBasePlate As Long Dim lFixity As Long Dim lAboveUID As Long Dim lSplice As Long Dim lLoadDB As Long Dim palNumStuds() As Long

'Double Dim dMemLength As Double Dim pdArea As Double Dim pdBfTop As Double Dim pdBfBot As Double

Module1 - 2

Dim pdTfTop As Double Dim pdTfBot As Double Dim pdDepth As Double Dim pdWebT As Double Dim dSectionPerimeter As Double Dim dX1 As Double Dim dY1 As Double Dim dZ1 As Double Dim dX2 As Double Dim dY2 As Double Dim dZ2 As Double Dim dPerimeterLength As Double Dim dConcThick As Double Dim dPolygonArea As Double Dim dHoleArea As Double Dim dP1X As Double Dim dP2X As Double Dim dP3X As Double Dim dP1Y As Double Dim dP2Y As Double Dim dP3Y As Double Dim dP1Z As Double Dim dP2Z As Double Dim dP3Z As Double Dim dP1P2 As Double Dim dP2P3 As Double Dim dP1P3 As Double Dim dTemp As Double Dim dWeight As Double Dim dUnitsFactor As Double Dim dDesignCamber As Double

Dim A As Double Dim B As Double Dim c As Double Dim dAngle As Double Dim dM1 As Double Dim dM2 As Double

'Enumerators Dim eBeamCoordLoc As eBeamCoordLoc Dim peBeamStatus As model_status Dim peColumnStatus As model_status Dim peFrameStatus As model_status Dim peShape As ESTEEL_SEC

'Strings Dim frameType As String

Type Props strDesig As String strRollFlg As String dDepth As Double dTw As Double dBfTop As Double dTfTop As Double dBfBot As Double dTfBot As Double dKTop As Double dKBot As Double dArea As Double dPerimeter As Double strShape As String End Type

Private Function GetSectionProps() As Props Dim SectionProps As Props

Set IMemberData1 = RamDataAcc1.GetDispInterfacePointerByEnum(IMemberData_INT) IMemberData1.GetSteelMemberSectionDimProps lMemberID, peShape, 1, pdBfTop, pdBfBot, pdTfTop, pdTfB ot, 1, 1, pdDepth, pdWebT, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, pdArea

Module1 - 3

If peShape = EStlWF Then SectionProps.dArea = pdArea SectionProps.dPerimeter = 2 * pdBfTop + 2 * pdDepth + 2 * pdBfBot - 2 * pdWebT SectionProps.dBfTop = pdBfTop SectionProps.strShape = "ISection" End If If peShape = EStlChannel Then SectionProps.dArea = pdArea SectionProps.dPerimeter = 2 * pdBfTop + 2 * pdDepth + 2 * pdBfBot - 2 * pdWebT SectionProps.dBfTop = pdBfTop SectionProps.strShape = "Channel" End If If peShape = EStlTube Then SectionProps.dArea = pdArea SectionProps.dPerimeter = 2 * pdBfTop + 2 * pdDepth SectionProps.dBfTop = pdBfTop SectionProps.strShape = "Tube" End If If peShape = EStlDoubleL Then SectionProps.dArea = 2 * pdArea SectionProps.dPerimeter = 4 * pdDepth + 4 * pdWebT SectionProps.dBfTop = 0 SectionProps.strShape = "DoubleAngle" End If If peShape = EStlFlatBar Then SectionProps.dArea = pdArea SectionProps.dPerimeter = pdBfTop * 2 + pdTfTop * 2 SectionProps.dBfTop = 0 SectionProps.strShape = "Bar" End If If peShape = EStlLSection Then SectionProps.dArea = pdArea SectionProps.dPerimeter = 2 * pdDepth + 2 * pdWebT SectionProps.dBfTop = 0 SectionProps.strShape = "Angle" End If If peShape = EStlNone Then SectionProps.dArea = 0 SectionProps.dPerimeter = 0 SectionProps.dBfTop = 0 SectionProps.strShape = "NA" End If If peShape = EStlPipe Then SectionProps.dArea = pdArea SectionProps.dPerimeter = pdDepth * 3.14159 SectionProps.dBfTop = 0 SectionProps.strShape = "Pipe" End If If peShape = EstlRoundBar Then SectionProps.dArea = pdArea SectionProps.dPerimeter = pdDepth * 3.14159 SectionProps.dBfTop = 0 SectionProps.strShape = "Rod" End If If peShape = EStlTSection Then SectionProps.dArea = pdArea SectionProps.dPerimeter = 2 * pdBfTop + 2 * pdDepth SectionProps.dBfTop = 0 SectionProps.strShape = "Tee" End If

GetSectionProps = SectionProps

End Function

Sub runThis() ' Define Variables

'Set version developed dVMin = 14.5

Module1

-

4

'Get Model path

OpenFile = Application.GetOpenFilename("RAM SS Database (*.ram; *.rss), *.ram; *.rss") If OpenFile = "" Or OpenFile = False Then Exit Sub End If

'Initialize DataAccess Set RamDataAcc1 = New RAMDATAACCESSLib.RamDataAccess1 'Set RamDataAcc1 = CreateObject("RAMDATAACCESSLib.RamDataAccess1") 'Initialize IO interface Set RamDataAccIDBIO = RamDataAcc1.GetDispInterfacePointerByEnum(IDBIO1_INT)

'Check to see if compatible version RamDataAccIDBIO.GetDatabaseVersion OpenFile, dVersion dVersion = Round(dVersion, 1) If dVersion < dVMin Then strVMin = dVMin MsgBox "This tool was written for Ram Structural System version " + strVMin + " or later. Ple ase update." Exit Sub End If

lLoadDB = RamDataAccIDBIO.LoadDataBase2(OpenFile, "DA") If lLoadDB <> 0 Then MsgBox "The model appears to be in use or is not consistent with the version of RAM Structural System on this machine." Exit Sub End If

'Initialize the Object Model Interface Set IModel = RamDataAcc1.GetDispInterfacePointerByEnum(IModel_INT)

' get Storeis

Set IStories = IModel.GetStories iNumStories = IStories.GetCount

ClearTable "outputTbl" ClearTable "columnsTbl" ClearTable "hbracesTbl" ClearTable "vbracesTbl" ClearTable "framereactionnodesTbl" ClearTable "gravityreactionnodesTbl" Set IStory = IStories.GetAt(0) strStoryID = IStory.strLabel 'Dim IReactionNodes As IReactionNodes 'Dim IreactionNode As IreactionNode Dim ILoadCases As ILoadCases Dim ILoadCase As ILoadCase Dim IPointLoad As IPointLoad Set ILoadCases = IModel.GetLoadCases(RAMFrameResultType) 'Set ILoadCases = IModel.GetLoadCases(DefaultResultType) 'set loadcombo = IModel.GetLoadCombinations(E

'ILoadCases.Filter eLoadCaseFilter_GeneratesDesignForces, True LoadCaseCount = ILoadCases.GetCount Dim c As Integer

c = 0

For lLc = 0 To (LoadCaseCount - 1) Set ILoadCase = ILoadCases.GetAt(lLc) strSymbol = ILoadCase.strLoadCaseGroupLabel 'If ILoadCase.eAnalyzedState = eStateCurrent And ILoadCase.eLdCaseMergeState = eSingleLoadCase The

n

'IStory.GetMemberReactionNodesFromFloorBelow

c

Dim INodes As INodes Set INodes = IModel.GetFrameAnalysisNodes

InodeCount = INodes.GetCount Dim INode As INode

=

c

+ 1

Module1 - 5

INodes.Filter eNFilter_AtFoundation, True InodeCount = INodes.GetCount Dim IMemberForces As IMemberForces Dim IMemberForce As IMemberForce For t = 0 To (InodeCount - 1) Set INode = INodes.GetAt(t)

Set IMemberForces = INode.GetReactions

Set IMemberForce = IMemberForces.Get(ILoadCase.lUID) Dim reactDict As New dictionary 'reactDict.Add "Floor", strStoryID 'reactDict.Add "c", ILoadCase.eLoadType 'reactDict.Add "d", ILoadCase.GetPrimaryLoadCases.GetCount 'reactDict.Add "e", ILoadCase.lUID 'reactDict.Add "lc", ILoadCase.lSubLoadType

reactDict.Add "LoadCaseSymbol", strSymbol reactDict.Add "LoadCase", ILoadCase.strTypeLabel reactDict.Add "FZ", IMemberForce.dAxial reactDict.Add "FX", IMemberForce.dShearMajor reactDict.Add "FY", IMemberForce.dShearMinor reactDict.Add "MXX", IMemberForce.dMomentMajor reactDict.Add "MYY", IMemberForce.dMomentMinor reactDict.Add "MZZ", IMemberForce.dTorsion reactDict.Add "X", INode.sLocation.dXLoc reactDict.Add "Y", INode.sLocation.dYLoc reactDict.Add "Z", INode.sLocation.dZLoc reactDict.Add "uniqueNodeID", INode.lUniqueID AddToTable reactDict, "framereactionnodesTbl" Set reactDict = Nothing

Next 'Set IStory = IStories.GetAt(1) 'Dim IRnds As IReactionNodes 'Dim IRnd As IreactionNode 'Dim someNodes As INodes 'Set someNodes = IStories.GetAt(3).GetIsolatedFnds.GetAt(1) 'IReactionNodes.Filter eRNFilterAtFoundation, True 'ICount = someNodes.GetCount

'Set some = abc.GetAt(0)

'For j = 0 To (irNodeCount - 1)

' Set IRnd = IRnds.GetAt(0)

' Set IMemberForces = IRnd.GetReactions(eFMFSGravityAnalysis)

' Set IMemberForce = IMemberForces.Get(ILoadCase.lUID)

' Dim graVreactDict As New dictionary 'reactDict.Add "Floor", strStoryID 'reactDict.Add "c", ILoadCase.eLoadType 'reactDict.Add "d", ILoadCase.GetPrimaryLoadCases.GetCount 'reactDict.Add "e", ILoadCase.lUID 'reactDict.Add "lc", ILoadCase.lSubLoadType

' graVreactDict.Add "LoadCaseSymbol", strSymbol

' graVreactDict.Add "LoadCase", ILoadCase.strTypeLabel

' graVreactDict.Add "FZ", IMemberForce.dAxial

' graVreactDict.Add "FX", IMemberForce.dShearMajor

' graVreactDict.Add "FY", IMemberForce.dShearMinor

'

graVreactDict.Add "MXX", IMemberForce.dMomentMajor

'

graVreactDict.Add "MYY", IMemberForce.dMomentMinor

'

graVreactDict.Add "MZZ", IMemberForce.dTorsion

'

graVreactDict.Add "X", INode.sLocation.dXLoc

''

graVreactDict.Add "Y", INode.sLocation.dYLoc

'

graVreactDict.Add "Z", INode.sLocation.dZLoc

'

reactDict.Add "uniqueNodeID", INode.lUniqueID

''

AddToTable graVreactDict, "gravityreactionnodesTbl"

'

Set graVreactDict = Nothing

'Next

Module1 - 6

'End If

'ReactionNodeCount = IReactionNodes.GetCount

' For lReact = 0 To (ReactionNodeCount - 1)

'

Set IReactionNode = IReactionNodes.GetAt(lReact)

'

Set IPointLoad = IReactionNode.GetReaction(eFMFSFrameAnalysis, ILoadCase.lAnalyzeNo)

'

Dim reactDict As dictionary

'

reactDict.Add "Floor", strStoryID

'

reactDict.Add "LoadCaseSymbol", strSymbol

'

reactDict.Add "dFx", IPointLoad.dFx

 

'

reactDict.Add "dFy", IPointLoad.dFy

''

reactDict.Add "dFz", IPointLoad.dFz

'

reactDict.Add "mFx", IPointLoad.mFx

'

reactDict.Add "mFy", IPointLoad.mFy

'

reactDict.Add "mFz", IPointLoad.mFz

'

AddToTable reactDict, "reactionnodesTbl"

'

Set reactDict = Nothing

'Next

Next

For lStory = 0 To (iNumStories - 1) Set IStory = IStories.GetAt(lStory) strStoryID = IStory.strLabel 'IModel.GetLoadCombinations (STEEL_CUSTOM).GetAt(1).CalculateForce(

' columns code

Set IColumns = IStory.GetColumns IColumns.Filter eColFilter_Material, ESteelMat lNumColumns = IColumns.GetCount Dim lColumn As Long For lColumn = 0 To lNumColumns - 1 Set IColumn = IColumns.GetAt(lColumn) lMemberID = IColumn.lUID member_num = IColumn.lLabel ' If member_num = 1 Then sect_lbl = IColumn.strSectionLabel prop = GetSectionProps IColumn.GetEndCoordinates pStartPoint, pEndPoint

dMemLength = Sqr((pStartPoint.dXLoc - pEndPoint.dXLoc) ^ 2 + (pStartPoint.dYLoc - pEndPoint.dY Loc) ^ 2 + (pStartPoint.dZLoc - pEndPoint.dZLoc) ^ 2) 'IBeam.GetCoordinates eBeamEnds, pStartPoint, pEndPoint If IColumn.eFramingType = MemberIsGravity Then

frameType = "Gravity" ElseIf IColumn.eFramingType = MemberIsLateral Then frameType = "Lateral" End If

Dim colDict As New dictionary

colDict.Add "Floor", strStoryID colDict.Add "ColumnNo", member_num colDict.Add "FrameType", frameType colDict.Add "SectionLbl", sect_lbl colDict.Add "SectionShp", prop.strShape colDict.Add "SectArea", prop.dArea colDict.Add "SectTop", prop.dBfTop colDict.Add "SectPerimeter", prop.dPerimeter colDict.Add "ColumnLength", dMemLength colDict.Add "StartX", pStartPoint.dXLoc

Module1 - 7

colDict.Add "StartY", pStartPoint.dYLoc colDict.Add "StartZ", pStartPoint.dZLoc

colDict.Add "EndX", pEndPoint.dXLoc colDict.Add "EndY", pEndPoint.dYLoc colDict.Add "EndZ", pEndPoint.dZLoc AddToTable colDict, "columnsTbl" Set colDict = Nothing

Next

'hbrace code starts

Set IHBraces = IStory.GetHorizBraces IHBraces.Filter eColFilter_Material, ESteelMat lNumHbraces = IHBraces.GetCount Dim lHbrace As Long For lHbrace = 0 To lNumHbraces - 1 Set IHBrace = IHBraces.GetAt(lHbrace) lMemberID = IHBrace.lUID member_num = IHBrace.lLabel

' If member_num = 1 Then sect_lbl = IHBrace.strSectionLabel prop = GetSectionProps IHBrace.GetEndCoordinates pStartPoint, pEndPoint dMemLength = Sqr((pStartPoint.dXLoc - pEndPoint.dXLoc) ^ 2 + (pStartPoint.dYLoc - pEndPoint.dY Loc) ^ 2 + (pStartPoint.dZLoc - pEndPoint.dZLoc) ^ 2) 'IBeam.GetCoordinates eBeamEnds, pStartPoint, pEndPoint

'If IColumn.eFramingType = MemberIsGravity Then

'

frameType = "Gravity"

'

ElseIf IColumn.eFramingType = MemberIsLateral Then

'

frameType = "Lateral"

'

End If

Dim hbraceDict As New dictionary

hbraceDict.Add "Floor", strStoryID hbraceDict.Add "ColumnNo", member_num hbraceDict.Add "SectionLbl", sect_lbl hbraceDict.Add "SectionShp", prop.strShape hbraceDict.Add "SectArea", prop.dArea hbraceDict.Add "SectTop", prop.dBfTop hbraceDict.Add "SectPerimeter", prop.dPerimeter hbraceDict.Add "ColumnLength", dMemLength hbraceDict.Add "StartX", pStartPoint.dXLoc hbraceDict.Add "StartY", pStartPoint.dYLoc hbraceDict.Add "StartZ", pStartPoint.dZLoc

hbraceDict.Add "EndX", pEndPoint.dXLoc hbraceDict.Add "EndY", pEndPoint.dYLoc hbraceDict.Add "EndZ", pEndPoint.dZLoc AddToTable hbraceDict, "hbracesTbl" Set hbraceDict = Nothing

Next

'vbrace code ends

'vbrace code starts

Set IVBraces = IStory.GetVerticalBraces IVBraces.Filter eColFilter_Material, ESteelMat lNumvbraces = IVBraces.GetCount Dim lvbrace As Long For lvbrace = 0 To lNumvbraces - 1 Set IVBrace = IVBraces.GetAt(lvbrace) lMemberID = IVBrace.lUID member_num = IVBrace.lLabel

' If member_num = 1 Then

Module1 - 8

sect_lbl = IVBrace.strSectionLabel prop = GetSectionProps IVBrace.GetEndCoordinates pStartPoint, pEndPoint dMemLength = Sqr((pStartPoint.dXLoc - pEndPoint.dXLoc) ^ 2 + (pStartPoint.dYLoc - pEndPoint.dY Loc) ^ 2 + (pStartPoint.dZLoc - pEndPoint.dZLoc) ^ 2) 'IBeam.GetCoordinates eBeamEnds, pStartPoint, pEndPoint

'If IColumn.eFramingType = MemberIsGravity Then

'

frameType = "Gravity"

'

ElseIf IColumn.eFramingType = MemberIsLateral Then

'

frameType = "Lateral"

'

End If

Dim vbraceDict As New dictionary

vbraceDict.Add "Floor", strStoryID vbraceDict.Add "ColumnNo", member_num vbraceDict.Add "SectionLbl", sect_lbl vbraceDict.Add "SectionShp", prop.strShape vbraceDict.Add "SectArea", prop.dArea vbraceDict.Add "SectTop", prop.dBfTop vbraceDict.Add "SectPerimeter", prop.dPerimeter vbraceDict.Add "ColumnLength", dMemLength vbraceDict.Add "StartX", pStartPoint.dXLoc vbraceDict.Add "StartY", pStartPoint.dYLoc vbraceDict.Add "StartZ", pStartPoint.dZLoc

vbraceDict.Add "EndX", pEndPoint.dXLoc vbraceDict.Add "EndY", pEndPoint.dYLoc vbraceDict.Add "EndZ", pEndPoint.dZLoc AddToTable vbraceDict, "vbracesTbl" Set vbraceDict = Nothing

Next

'vbrace code ends

'Get member ID lists on Story

Set IBeams = IStory.GetBeams IBeams.Filter eBeamFilter_Material, ESteelMat lNumBeams = IBeams.GetCount Dim lBeam As Long For lBeam = 0 To lNumBeams - 1

Set IBeam = IBeams.GetAt(lBeam) lMemberID = IBeam.lUID member_num = IBeam.lLabel

' If member_num = 1 Then

sect_lbl = IBeam.strSectionLabel camber = IBeam.dCamber prop = GetSectionProps IBeam.GetCoordinates eBeamEnds, pStartPoint, pEndPoint

Set ISteelBeamDesignResult = IBeam.GetSteelDesignResult Dim numStudsDAArray As RAMDATAACCESSLib.DAArray Set numStudsDAArray = ISteelBeamDesignResult.GetNumStudsInSegments

Dim designedCamber Dim pSize As Long

' determin frame type

Module1 - 9

If IBeam.eFramingType = MemberIsGravity Then

frameType = "Gravity"

If IBeam.bComposite = 1 Then ReDim palNumStuds(0 To 4) As Long IBeam.GetSteelDesignResult.GetNumStudsInSegments.GetSize pSize

For lStudSeg = 0 To pSize - 1 IBeam.GetSteelDesignResult.GetNumStudsInSegments.GetAt lStudSeg, k lTotalStuds = lTotalStuds + k palNumStuds(lStudSeg) = k

Next

For onWards = pSize To UBound(palNumStuds) palNumStuds(onWards) = 0

Next

Else lTotalStuds = 0 End If

ElseIf IBeam.eFramingType = MemberIsLateral Then frameType = "Lateral"

If IBeam.bComposite = 1 Then ReDim palNumStuds(0 To 4) As Long lTotalStuds = 0

IBeam.GetSteelDesignResult.GetNumStudsInSegments.GetSize pSize

For lStudSeg = 0 To pSize - 1 IBeam.GetSteelDesignResult.GetNumStudsInSegments.GetAt lStudSeg, k lTotalStuds = lTotalStuds + k palNumStuds(lStudSeg) = k

Next

For onWards = pSize To UBound(palNumStuds) palNumStuds(onWards) = 0

Next

Else lTotalStuds = 0 End If

End If

dMemLength = Sqr((pStartPoint.dXLoc - pEndPoint.dXLoc) ^ 2 + (pStartPoint.dYLoc - pEndPoint.dY Loc) ^ 2 + (pStartPoint.dZLoc - pEndPoint.dZLoc) ^ 2)

Dim dict As New scripting.dictionary

dict.Add "Floor", strStoryID dict.Add "BeamNo", member_num dict.Add "FrameType", frameType dict.Add "SectionLbl", sect_lbl dict.Add "SectionShp", prop.strShape dict.Add "SectArea", prop.dArea dict.Add "SectTop", prop.dBfTop dict.Add "SectPerimeter", prop.dPerimeter dict.Add "BeamLength", dMemLength

Module1 - 10

dict.Add "StartX", pStartPoint.dXLoc dict.Add "StartY", pStartPoint.dYLoc dict.Add "StartZ", pStartPoint.dZLoc

dict.Add "EndX", pEndPoint.dXLoc dict.Add "EndY", pEndPoint.dYLoc dict.Add "EndZ", pEndPoint.dZLoc

dict.Add "Camber", IBeam.dCamber dict.Add "StudDiameter", IBeam.dStudDiameter dict.Add "StudLength", IBeam.dStudLength

dict.Add "StudSegmentLength1", IBeam.dStudSegment1Length dict.Add "StudSegmentLength2", IBeam.dStudSegment2Length dict.Add "StudSegmentLength3", IBeam.dStudSegment3Length dict.Add "StudSegmentLength4", IBeam.dStudSegment4Length dict.Add "StudSegmentLength5", IBeam.dStudSegment5Length dict.Add "NumOfStud1", palNumStuds(0) dict.Add "NumOfStud2", palNumStuds(1) dict.Add "NumOfStud3", palNumStuds(2) dict.Add "NumOfStud4", palNumStuds(3) dict.Add "NumOfStud5", palNumStuds(4)

AddToTable dict, "outputTbl" Set dict = Nothing

Next

Next

'End If

'For Each ws In ThisWorkbook.Worksheets

' For Each lstobj In ws.ListObjects

' If lstobj.Name = "outputTbl" Then ' lstobj.ListColumns(1).Delete

'

End If

'

Next

'Next

RamDataAccIDBIO.CloseDatabase

End Sub

Sub ClearTable(tblName) Dim lo As ListObject For Each ws In ThisWorkbook.Worksheets For Each lstobj In ws.ListObjects If lstobj.Name = tblName Then lstobj.Delete Set lo = ws.ListObjects.Add(xlSrcRange, ws.Range("$A$4"), , xlYes) lo.Name = tblName lo.ListRows.Add AlwaysInsert:=True

Next

Next

End If

'Dim wsh As Worksheet 'Set wsh = ThisWorkbook.Worksheets(1)

'Set lo = wsh.ListObjects.Add(xlSrcRange, Range("$A$4"), , xlYes) 'lo.Name = "outputTbl" 'lo.ListRows.Add AlwaysInsert:=True End Sub

Module1 - 11

Sub AddToTable(dict As scripting.dictionary, tblName)

Dim wkBk As Workbook Dim wksht As Worksheet Dim lo As ListObject Dim lstobj As ListObject

Set wkBk = Application.ThisWorkbook

For Each ws In ThisWorkbook.Worksheets For Each lstobj In ws.ListObjects If lstobj.Name = tblName Then AddDictToTbl lstobj, dict

Next

Next

End Sub

End If

Public Function DoesTableExist(ByVal wb As Workbook, _ ByVal tblName As String) As Boolean On Error GoTo catch

DoesTableExist = False

Dim lstobj As ListObject, ws As Worksheet

For Each ws In wb.Worksheets For Each lstobj In ws.ListObjects If lstobj.Name = tblName Then DoesTableExist = True Exit Function End If

Next

Next

Exit Function catch:

DoesTableExist = False End Function

Public Function AddDictToTbl(lo As ListObject, dict As scripting.dictionary)

Dim hr As Range Set hr = lo.HeaderRowRange

For Each k In dict.Keys If Application.WorksheetFunction.CountIf(hr, k) > 0 Then

Else lo.ListColumns.Add lo.HeaderRowRange.End(xlToRight) = k End If

Next

'lo.ListColumns("Column1").Delete

Dim rowRng As ListRow 'lo.ListRows.Add AlwaysInsert:=True

Set rowRng = lo.ListRows(lo.ListRows.Count) Dim colRng As Range Dim tarRng As Range

For Each Key In dict.Keys ' find column no from key Set colRng = lo.ListColumns(Key).Range

Module1 - 12

Set tarRng = colRng(lo.ListRows.Count + 1) tarRng = dict(Key)

Next

lo.ListRows.Add AlwaysInsert:=True If HeaderExists(lo, "Column1") Then

lo.ListColumns("Column1").Delete

End If

End Function Public Function HeaderExists(tbl As ListObject, HeaderName As String) As Boolean

'PURPOSE: Output a true value if column name exists in specified table 'SOURCE: www.TheSpreadsheetGuru.com

Dim hdr As ListColumn

On Error GoTo DoesNotExist

Set hdr = tbl.ListColumns(HeaderName) On Error GoTo 0

HeaderExists = True

Exit Function

'Error Handler DoesNotExist:

Err.Clear HeaderExists = False

End Function