I am trying to programmatically access data from a RAM SS file by following this guide(VB in Excel).
The Excel file crashes when I try to call any method which fetches data from a file eg
Set IStories = IModel.GetStories lNumStories = IStories.GetCount
These methods do work in some cases which must be like 10% of the number of times I've tried across multiple computers.
The input file I am using is correct as it loads correctly in the GUI app.
Also initialization methods always work eg: Set RamDataAcc1 = New RAMDATAACCESSLib.RamDataAccess1 Set RAMDataAccIDBIO = RamDataAcc1.GetDispInterfacePointerByEnum(IDBIO1_INT) RAMDataAccIDBIO.GetDatabaseVersion OpenFile, dVersion dVersion = Round(dVersion, 1) SendToLogFile ("Version: " & dVersion) RAMDataAccIDBIO.LoadDataBase2 OpenFile, "work"
The full file I am using:
Public Sub MyTest() Dim OpenFile As String Dim RamDataAcc1 As RamDataAccess1 Dim RAMDataAccIDBIO As RAMDATAACCESSLib.IDBIO1 Dim dVersion As Double Dim IModel As RAMDATAACCESSLib.IModel Dim IStories As RAMDATAACCESSLib.IStories Dim IStory As RAMDATAACCESSLib.IStory Dim IFloorTypes As RAMDATAACCESSLib.IFloorTypes Dim IBeams As RAMDATAACCESSLib.IBeams Dim IBeam As RAMDATAACCESSLib.IBeam Dim lNumStories As Long Dim lStory As Long Dim strStoryID As String Dim lNumBeams As Long Dim lBeam As Long SendToLogFile ("-------------------------------") OpenFile = "D:\Projects\workDesk\RAM\project\r2.rss" 'Initialize DataAccess Set RamDataAcc1 = New RAMDATAACCESSLib.RamDataAccess1 'Initialize IO interface Set RAMDataAccIDBIO = RamDataAcc1.GetDispInterfacePointerByEnum(IDBIO1_INT) RAMDataAccIDBIO.GetDatabaseVersion OpenFile, dVersion dVersion = Round(dVersion, 1) SendToLogFile ("Version: " & dVersion) RAMDataAccIDBIO.LoadDataBase2 OpenFile, "work" Set IModel = RamDataAcc1.GetDispInterfacePointerByEnum(IModel_INT) Set IStories = IModel.GetStories lNumStories = IStories.GetCount For lStory = 0 To (lNumStories - 1) 'Getting story info Set IStory = IStories.GetAt(lStory) strStoryID = IStory.strLabel 'Get member ID lists on story Set IBeams = IStory.GetBeams IBeams.Filter eBeamFilter_Material, ESteelMat lNumBeams = IBeams.GetCount For lBeam = 0 To lNumBeams - 1 Set IBeam = IBeams.GetAt(lBeam) SendToLogFile ("IBeam: " & lBeam) Next Next SendToLogFile ("END")End Sub
SendToLog is correctly defined and definitely not a problem. Trusted locations, file paths etc are also correct.
Excel just crashes so not sure what more info I can provide.
Thanks for any help!