Good morning everyone!
I'm trying to integrate excel with other software (the EES - Engineering Equation Solver) through vba code.
My program copies certain columns from a table, transfers to the other program, performs the calculations, copies the results, and pastes the corresponding columns of my table into excel. The EES help site itself provides a sample program for operation, which I am using as a basis.The problem is that my program returns decimal values and excel is not recognizing the comma of the pasted data! The strange thing is that decimal data copied from excel to EES is interpreted correctly and if I copy and paste the EES data manually into the spreadsheet the number comes with the comma correctly!
My excel is already set to recognize comma as decimal separator, equal to EES. The code is as follows:
Private Sub cmdDDE_Click()
Dim ChNumber As Integer
Dim myShell As String
ChNumber = -1
myShell = frmEESDDE.txtApp.Text
On Error Resume Next
'Copy selected rows into clipboard
Range("B2:G1401").Select
Selection.Copy
Shell_R = Shell(myShell, 1)
If Shell_R <> "" Then
'Initiate DDE
ChNumber = Application.DDEInitiate(app:="ees", topic:="")
If ChNumber <> -1 Then
'Open EES
Application.DDEExecute ChannelNumber, "[Open C:\EES\Tablesolve.ees]"
'Paste data
Application.DDEExecute ChannelNumber, "[Paste Parametric 'Table 1' R1 C1]"
'Solve parametrictable
Application.DDEExecute ChannelNumber, "[SOLVETABLE 'TABLE 1' Rows=1..1400]"
'Copy results
Application.DDEExecute ChannelNumber, "[COPY ParametricTable 'Table 1' R1 C7:R1400 C14]"
'Choose separators
Application.DecimalSeparator = ","
Application.ThousandsSeparator = "."
Application.UseSystemSeparators = False
'Paste results from EES into EXCEL
Application.Paste Destination:=Worksheets("Sheet1").Range("H2:O1440")
Application.UseSystemSeparators = True
'Quit EES and Terminate DDE
DDEExecute ChNumber, "QUIT"
Application.DDETerminate ChNumber
Else
MsgBox "Unable to initiate connection to EES", vbExclamation, "EES DDE"
End If
frmEESDDE.Hide
Else
MsgBox "The application, " & myShell & ", was not found", vbExclamation, "EES DDE"
End If
End Sub
PS = Note that I already tried using the Application.DecimalSeparator="," command but it did not work. My result of, for example, "15,47" appears in excel as "1.55E + 12" or as "1547421377050".
Thanks in advance for the help!