Hello Archie - tried this today, but no success.
I wasn't familiar with the exact subroutine Declaration to paste the code ahead of. Here is the MainForm.vb code I tried after adding the reference to Excel to the AdvancedHMI project. I am using Excel Pro 2010 and Visual Basic 2010 Express
Public Class MainForm
Private oXL As Excel.Application
Private oWB As Excel.Workbook
Private oSheet As Excel.Worksheet
Private Sub MainForm_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
' Start Excel and get Application object.
oXL = CreateObject("Excel.Application")
oXL.Visible = True
' Get a new workbook.
oWB = oXL.Workbooks.Add
oSheet = oWB.ActiveSheet
End Sub
Private Sub DataSubscriber1_DataChanged(ByVal sender As Object, ByVal e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
oSheet.Cells(1, 1).Value = e.values(0)
End Sub
Private Sub MainForm_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MainForm))
Dim x = CType(resources.GetObject("MessageListByValue1.Messages"), MfgControl.AdvancedHMI.Controls.MessageByValue)
End Sub
'*******************************************************************************
'* Stop polling when the form is not visible in order to reduce communications
'* Copy this section of code to every new form created
'*******************************************************************************
Private Sub Form_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
AdvancedHMIDrivers.Utilities.StopComsOnHidden(components, Me)
End Sub
'**************************************
'* Filling the form with a gradient
'**************************************
Private Sub MainForm_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
'Dim rect As New System.Drawing.Rectangle(0, 0, e.ClipRectangle.Width, e.ClipRectangle.Height)
'Dim gradientBrush As New Drawing.Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(0, Height), System.Drawing.Color.FromArgb(180, 100, 200), System.Drawing.Color.FromArgb(110, 200, 255))
'e.Graphics.FillRectangle(gradientBrush, rect)
End Sub
End Class
Error 1 Type 'Excel.Application' is not defined. F:\AdvancedHMI\AdvancedHMIBetaV397e\AdvancedHMI\MainForm.vb 3 20 AdvancedHMI
Error 2 Type 'Excel.Workbook' is not defined. F:\AdvancedHMI\AdvancedHMIBetaV397e\AdvancedHMI\MainForm.vb 4 20 AdvancedHMI
Error 3 Type 'Excel.Worksheet' is not defined. F:\AdvancedHMI\AdvancedHMIBetaV397e\AdvancedHMI\MainForm.vb 5 23 AdvancedHMI
Error 4 'Private Sub MainForm_Load(sender As Object, e As System.EventArgs)' has multiple definitions with identical signatures. F:\AdvancedHMI\AdvancedHMIBetaV397e\AdvancedHMI\MainForm.vb 7 17 AdvancedHMI
I am hoping to sort of build a very basic HMI within Excel that populates the Excel cells with real time live data at an update rate that is suitable for end to end transmitter calibrations.
Preserving the values as a record would be done manually as I present different PVs to a given transmitter, and then use Copy, & Paste Value on the transmitter PV to record it on another worksheet in Excel.
Here is a snippet from Excel of what I am doing with it using RSLinx to make a crude HMI that I grab values from:
PLC Address, Live Value Displayed, Tag Info, Old PLC5 Tag info
SCADA_REAL[29] 717.3 PT-001 METER 1 PRESSURE PT-001 TO GC$N(FC3:158) METER 1 PRESSURE PT-001 TO GC$N(FC3:158)
SCADA_REAL[30] 45.5 TT-001 METER 1 TEMPERATURE TT-001 TO GC$N(FC3:160) METER 1 TEMPERATURE TT-001 TO GC$N(FC3:160)
SCADA_REAL[32] 718.0 PT-002 METER 1 PRESSURE PT-002 TO GC$N(FC3:164) METER 1 PRESSURE PT-002 TO GC$N(FC3:164)
SCADA_REAL[33] 45.8 TT-002 METER 1 TEMPERATURE TT-002 TO CG (FC3:166) METER 1 TEMPERATURE TT-002 TO CG (FC3:166)
SCADA_REAL[35] 716.4 PT-901 DISCHARGE PRESSURE PT-901 TO GC (FC3:170) DISCHARGE PRESSURE PT-901 TO GC (FC3:170)
Thanks,
Ed