How do I set up a COM Server interface with Excel?

Excel 2003
Windows XP
SimaPro 7.3.0 Developer Version
Using a Work computer but was made administrator on this machine
Libraries referenced in Excel/VBA: Visual Basic for Applications; Microsoft Excel 11.0 Object Library; OLE Automation; Microsoft Office 11.0 Object Library; Microsoft Forms 2.0 Object Library; COM+ 1.0 Admin Type Library; COM MakeCab 1.0 Type Library; COM+ Services Type Library; SimaPro Library
Me: Beginner **What I'm trying to do** I am using a program called SimaPro that stores databases of "Life Cycle Analysis" information. The program has built in COM interface functionality. The program states that it does, indeed support Excel/VBA (but it doesn't specify versions). I am trying to connect this program and/or COM server to excel so that I can interact with the information through excel. **What I've done**
I've done the procedure they list:
-Open SimaPro
-Register COM Server
-Then I pasted the below code into VBA and tried to run it. This code is the sample code provided by the software company, I edited only the SP.Server, SP.Alias, SP.Login, and SP.OpenProject fields (below is as edited).

**What Happened**
Run-time Error: '-2147418113 (8000ffff)':
Automation Error
Catastrophic Failure
-Is the server name right? I've been reading a little on COM servers and I don't know if the way I put it in is in the right "form"
-Could it have something to do with certain registered/unregistered DLLs? I've worked with the company's IT people, and software programmers. None of them were very familiar with COM but one person suggested the DLLs might be the issue. **Thanks for your help!!** _**Here is the code that I'm inputting:**_ Sub CreateProcess() Dim SP As SimaProServer Dim PC As Process Dim PC2 As Process Dim PL As ProcessLine Dim Param As ParamLine Dim Subs As Substance Set SP = New SimaProServer SP.Server = "Local Server" SP.Alias = "C:\Documents and Settings\All Users\Documents\SimaPro\Database\" SP.Database = "Professional" SP.OpenDatabase SP.Login "", "" SP.OpenProject "PROJECT", "" ' Not project's actual name, not allowed to state name of project SP.CreateSubstance "Air", Subs Subs.CASNumber = "4-5-13" Subs.Name = "Some substance" Subs.DefaultUnit = "kg" Subs.Update SP.CreateProcess ptMaterial, PC Set PL = PC.AddLine(ppProduct, -1) PL.ObjectName = "Steel 2" PL.UnitName = "kg" PL.Amount = "2" PL.Comment.Add ("My new created process") PL.CategoryPath = "Chemicals\inorganic" PC.Update ' create second material process Case SP.CreateProcess ptMaterial, PC2 Set PL = PC2.AddLine(ppProducts, 0) PL.ObjectName = "Case 2" PL.UnitName = "kg" PL.Amount = "10" Set Param = PC2.AddParamLine(ptInputParameter, -1) Param.Name = "A" Param.Value = "2,3" ' add input from Steel Set PL = PC2.AddLine(ppMaterialsFuels, -1) ' input from steel PL.SetProduct "Introduction to SimaPro 7", ptMaterial, "Steel 2" PL.Amount = "8" PL.UnitName = "kg" Set PL = PC2.AddLine(ppAirborneEmissions, -1) ' input from steel PL.SetSubstance "Some substance", "" PL.Amount = "A+1" PL.UnitName = "kg" PC2.Update SP.Logout SP.CloseDatabase Set SP = Nothing End Sub
please format your code as code otherwise it's a real pain to read. I'll do it for you this time.

以上就是How do I set up a COM Server interface with Excel?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » excel

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准