Creating Excel Sheet using VB 2005

M

mdup

I am trying to connect to servers and import data and attributes from the
servers into excel. What is the best way to do this? I have to connection
part of the code wriitten and can connect to any server I choose. I am not
working on creating the excel spreadsheet with the data.

I have Imported the Microsoft.Office.Interop.Excel package into my program.
Should I be using the ListColumns.Add and the ListRows.Add functions to
populate the spreadsheet from the data imported by the server?

Thanks in advance.
 
M

mdup

mdup said:
I am trying to connect to servers and import data and attributes from the
servers into excel. What is the best way to do this? I have to connection
part of the code wriitten and can connect to any server I choose. I am now
working on creating the excel spreadsheet with the data.

I have Imported the Microsoft.Office.Interop.Excel package into my program.
Should I be using the ListColumns.Add and the ListRows.Add functions to
populate the spreadsheet from the data imported by the server?

Thanks in advance.
 
M

mdup

Sorry I mistyped some of the initial post. I am NOW (instead of not) working
on creating the excel spreadsheet with the data. I have been using the Object
Browser to try and find the commands I need to use to import the data. Below
is a code i have written to import the data but it does have some issues.



#Region " (Import Data) This function will import the PI Tag Names and
desired Attributes into an Excel worksheet "
Private Sub Import()
'Declare Variables for Data Retrevial

'Dim srv As Server ' server object
Dim nvs As PISDKCommon.NamedValues 'list of attribute names to
get
Dim piPoint As PIPoint
Dim pAttrs As PISDKCommon.NamedValues
Dim pAtt As PISDKCommon.NamedValue
Dim pList As PointList
Dim getEx As IGetPoints2
Dim List1 As Excel.RTD
Dim List2 As Excel.RTD

On Error GoTo err
getEx = myServer


pList = getEx.GetPoints2("tag='" & " * " & "'", nvs,
GetPointsRetrievalTypes.useGetPoints)
For Each piPoint In pList
List1.AddItem(piPoint.Name)
Next
Exit Sub
err:
MsgBox("Error in call:" & Err.Description)

On Error Resume Next

List2.Clear()
piPoint = myServer.PIPoints(List1.Text)
pAttrs = piPoint.PointAttributes.GetAttributes 'Fetch returned
attributes as NamedValues
For Each pAtt In pAttrs 'Run thru all attributes
List2.AddItem(pAtt.Name & ": " & CStr(pAtt.Value)) 'Show name
and value
Next

nvs = New PISDKCommon.NamedValues
nvs.Add("archiving", 1)



And more attributes follow the nvs.Add("archiving") line. I am also not sure
if this is how List1 and List2 should be defined Dim List1 As Excel.RTD, Dim
List2 As Excel.RTD. I thought more details on the code and and problem I am
having would help. The code is being written so that it does not require any
clicking to operate. This should be an automated process.

Thanks again in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top