Cancel
Showing results for 
Search instead for 
Did you mean: 

Live Export to Excel

Experimenter
Experimenter

Hello guys,

 

I am trying to send live data to excel via the DDE/COM-interface. I am able to establish a channel but somehow, the data is not written in to excel (screenshot). My plan was to execute the yellow VBA-code every x-seconds, so that I can get a "live" data transfer. 

Does anyone know where the problem is?

 

Thank you.

13 REPLIES

Re: Live Export to Excel

Phenom
Phenom

I cannot reproduce what you have posted.

 

Therfore please send your model plus XLm file to check

 

 

Re: Live Export to Excel

Experimenter
Experimenter

Hi simulator,

 

I attached my model and here is the VBA code:

 

Sub COM()

Dim PS As Object
Set PS = CreateObject("Tecnomatix.PlantSimulation.RemoteControl.13.0")
    
    If PS Is Nothing Then
        Debug.Print "error"
        Stop
    End If
    
PS.loadmodel ("F:\Frachtflughafen.spp")
PS.setVisible (True)
PS.startSimulation (".Modelle.Netzwerk.Ereignisverwalter")

Tabelle1.Cells(1, 1).Value = PS.GetValue(".Modelle.Netzwerk.Strecke_Tugs.Einzelstation1.ProcTime")

End Sub
Sub DDE()

Dim channel As Long

channel = DDEInitiate("eM-Plant", "System")

DDEExecute channel, ".Modelle.Netzwerk.Ereignisverwalter.reset;"
DDEExecute channel, ".Modelle.Netzwerk.Ereignisverwalter.start;"

Tabelle1.Range("A1").Value = DDERequest(channel, ".Modelle.Netzwerk.Strecke_Tugs.Einzelstation1.ProcTime")

DDETerminate (channel)
End Sub

The COM-interface produces the error that I mentioned and the DDE-interface works but it does not write the data into excel.

Thank you in advance. 

Re: Live Export to Excel

Phenom
Phenom

I run your macro  with  a xlsm 2013 file  and it worked.

 

Could have something to do with your XL.

 

To focus the problem try the following code

 

 

Sub COM()

Dim PS As Object
Set PS = CreateObject("Tecnomatix.PlantSimulation.RemoteControl.13.0")
    
    If PS Is Nothing Then
        Debug.Print "error"
        Stop
    End If
    
PS.loadmodel ("F:\Frachtflughafen.spp")

' PS.loadmodel ("c:\temp\Frachtflughafen.spp")

PS.setVisible (True)
PS.startSimulation (".Modelle.Netzwerk.Ereignisverwalter")

dim r as single
r = PS.GetValue(".Modelle.Netzwerk.Strecke_Tugs.Einzelstation1.ProcTime")
tabelle1.cells(1,1).value = r
End Sub

 

 

 

Re: Live Export to Excel

Experimenter
Experimenter

I ran your code but i still get an error message:

 

error.JPG

 

Im using excel 2013 and plant simulation 13 (64bit) 13.0.5

Re: Live Export to Excel

Phenom
Phenom

yes, but in which vba row did the error appear ?

 

r=ps.getvalue...

 

or

 

tabelle.cells(1,1).value ....

Re: Live Export to Excel

Experimenter
Experimenter

I just checked:

The problem appears already when I try to load the model. When this VBA row get executed:

PS.loadmodel ("F:\Frachtflughafen.spp")

Re: Live Export to Excel

Phenom
Phenom
is drive "F" a net or local drive ?

In any case try to load from local c:\temp folder

Re: Live Export to Excel

Experimenter
Experimenter

Same problem when I copy the file to c:\temp and try to run it from there..

Re: Live Export to Excel

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
I had the same problem, I had to make some security settings in the folder (impossible for c:\), excel access the file with a different "user", the root folders are protected in windows 7 and above, so you need to create a folder and grant access rights for "all users" (execute).
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net