VBA with Citect SCADA - Reports exel

Прочие SCADA: iFix, InTouch, Citect, ...
daocongdabl
Posts: 9
Joined: Wed Jun 09, 2010 2:48 pm

VBA with Citect SCADA - Reports exel

Post by daocongdabl »

I Am having difficulty in Citect to report data from excel file
I do not know how to write down the value of Variable Tags excel file.
I used in the project named tag1

I do not know how to write the value "tag1" to excel
with this code, it's time to call Citect executable files but not write the value
to excel

someone help me with the code above runs ok (tyou) (tyou)
I will send one key Citect 7.5 crack


(clap) (clap) (clap)
code://///////////////////
Sub WriteToExcelFile()

Dim objExcelApp As Object

Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
'ExcelExample.xls is to create before executing this procedure.
'Replace with the real path of the file ExcelExample.xls.
objExcelApp.Workbooks.Open "D:\report.xls "
objExcelApp.Cells(2, 2).Value= tag1.Value
objExcelApp.Cells(3, 2).Value = 1
objExcelApp.Cells(4, 2).Value = 2
objExcelApp.ActiveWorkbook.Save

objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing
End Sub
////////////////////
daocongdabl
Posts: 9
Joined: Wed Jun 09, 2010 2:48 pm

Re: VBA with Citect SCADA - Reports exel

Post by daocongdabl »

Their use Citect VBA to export data into Excel her difficulty is how to access the value of the variable.
For example, a variable declared himself in Variable Tag. Then show the value of this variable to Excel (using VBA), but I do not know the value of the variable called like?
WinCC is used in HMIRuntime.Tags function ("Tag") also in Citect, use what function?

sorry my english is bad
I'm from Vietnam
daocongdabl
Posts: 9
Joined: Wed Jun 09, 2010 2:48 pm

Re: VBA with Citect SCADA - Reports exel

Post by daocongdabl »

VBA with Citect SCADA - Reports exel

Postby daocongdabl » Tue Apr 19, 2016 12:28 pm
I Am having difficulty in Citect to report data from excel file
I do not know how to write down the value of Variable Tags excel file.
I used in the project named tag1

I do not know how to write the value "tag1" to excel
with this code, it's time to call Citect executable files but not write the value
to excel

someone help me with the code above runs ok (tyou) (tyou)
I will send one key Citect 7.5 crack


(clap) (clap) (clap)
code://///////////////////
Sub WriteToExcelFile()

Dim objExcelApp As Object
Help (tyou) help (tyou)


someone help me with the code above runs ok (tyou) (tyou)
I will send one key Citect 7.5 crack

daocongdabl@gmail.com



Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
'ExcelExample.xls is to create before executing this procedure.
'Replace with the real path of the file ExcelExample.xls.
objExcelApp.Workbooks.Open "D:\report.xls "
objExcelApp.Cells(2, 2).Value= tag1.Value
objExcelApp.Cells(3, 2).Value = 1
objExcelApp.Cells(4, 2).Value = 2
objExcelApp.ActiveWorkbook.Save

objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing
End Sub
PCNightmare
Posts: 4
Joined: Thu Feb 07, 2013 8:21 am

Re: VBA with Citect SCADA - Reports exel

Post by PCNightmare »

This is what I have done in past:
1. Citect writes data to .csv file
2. Execute excel (from citect) to and load with autorun macro within excel. Maco to load and process the CSV writing it into the required cells
3. From macro other required functions such as print, save as new excel file etc..
daocongdabl
Posts: 9
Joined: Wed Jun 09, 2010 2:48 pm

Re: VBA with Citect SCADA - Reports exel

Post by daocongdabl »

Thank you for interested reply

csv file export problem, I do ok

but the project I need is to use Citect VBA report to excel
and I want to know my code is wrong somewhere
daocongdabl
Posts: 9
Joined: Wed Jun 09, 2010 2:48 pm

Re: VBA with Citect SCADA - Reports exel

Post by daocongdabl »

help (h) help (h) (sos) (sos) (sos)


code://///////////////////
Sub WriteToExcelFile()

Dim objExcelApp As Object

Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
'ExcelExample.xls is to create before executing this procedure.
'Replace with the real path of the file ExcelExample.xls.
objExcelApp.Workbooks.Open "D:\report.xls "
objExcelApp.Cells(2, 2).Value=

Code: Select all

[color=#FF0000]tag1.Value[/color]
[/b] ////////I do not know how to declare this true or not?///

objExcelApp.Cells(3, 2).Value = 1
objExcelApp.Cells(4, 2).Value = 2
objExcelApp.ActiveWorkbook.Save

objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing
End Sub
////////////////////

This code is wrong somewhere? I can not write the value of tag1 Citect project
PCNightmare
Posts: 4
Joined: Thu Feb 07, 2013 8:21 am

Re: VBA with Citect SCADA - Reports exel

Post by PCNightmare »

Maybe need to read tag1 value into a string???

Dim sTag as string;

sTag=tagread("tag1");

objExcelApp.Cells(2, 2).Value=sTag;
morbiusmn
Posts: 9
Joined: Wed Oct 02, 2013 6:43 pm

Re: VBA with Citect SCADA - Reports exel

Post by morbiusmn »

If "tag1" is the variable in your citect scada, you just have to put it like the code below

I used this code in my software and works well.


Sub WriteToExcelFile()

Dim objExcelApp As Object

Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
'ExcelExample.xls is to create before executing this procedure.
'Replace with the real path of the file ExcelExample.xls.
objExcelApp.Workbooks.Open "D:\report.xls "
objExcelApp.Cells(2, 2).Value= tag1
objExcelApp.Cells(3, 2).Value = 1
objExcelApp.Cells(4, 2).Value = 2
objExcelApp.ActiveWorkbook.Save

objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing

End Sub
Last edited by morbiusmn on Mon Mar 05, 2018 5:08 pm, edited 1 time in total.
morbiusmn
Posts: 9
Joined: Wed Oct 02, 2013 6:43 pm

Re: VBA with Citect SCADA - Reports exel

Post by morbiusmn »

I did this script to create a csv file.

In this model, TAG1 e TAG2 are tags in your citect scada.

'-----------------------------------------------------------------

'Diretório dos Arquivos CSV
Dim Pasta
Pasta = "C:\Setpoints\"

Dim Obj01 As Object
Set Obj01 = CreateObject("Scripting.FileSystemObject")

If Obj01.FolderExists(Pasta) = True Then
'MsgBox "EXISTE!"
End If

'Data e Hora Atual do Sistema
Dim Ano, Mes, Dia, Horas
Ano = Year(Now)
Mes = Month(Now)
Dia = Day(Now)
Horas = Time

'Verifica Condição para salvar Arquivo CSV
Dim Obj00 As Object
Dim FileSpec, Arquivo

'Especifica o arquivo a ser criado oo modificado:
Arquivo = Ano & Mes & Dia & "_" & "Relatorio_Setpoints" & ".csv"
FileSpec = Pasta & Arquivo

Dim ForWriting
ForWriting = 8
Dim Linha
Linha = 0

If Linha = 0 Then

Set Obj00 = CreateObject("Scripting.FileSystemObject")
Dim objtxt As Object
Set objtxt = Obj00.CreateTextFile(FileSpec, True)
objtxt.Close

ForWriting = 2

MsgBox "CSV foi salvo com sucesso em: " & FileSpec

End If

'Armazena os valores no arquivo:
Dim File As Object
Set File = Obj01.OpenTextFile(FileSpec, ForWriting, True)

'Escreve as linhas no arquivo
'Dados iniciais
Dim Cabecalho
Dim M60TC00

'Monta Cabeçalho do CSV
Cabecalho = "Tag;Horímetro Atual;Setpoint Atribuído"

'Dados da 2° Linha do CSV
M60TC00 = "60TC00" & ";" & TAG1 & ";" & TAG2

'Preenche a 1° Monta Cabeçalho do CSV
File.WriteLine CStr(Cabecalho)

'Preenche a 2° Linha do CSV
File.WriteLine CStr(M60TC00)
morbiusmn
Posts: 9
Joined: Wed Oct 02, 2013 6:43 pm

Re: VBA with Citect SCADA - Reports exel

Post by morbiusmn »

If you just want to read a value from Excel and write to a tag, use the example below, where "tag1" is the tag in your Citect Scada.

I used this code in my software and works well.


Sub ReadFromExcelFile()

Dim objExcelApp As Object

Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
'ExcelExample.xls is to create before executing this procedure.
'Replace with the real path of the file ExcelExample.xls.
objExcelApp.Workbooks.Open "D:\report.xls "
tag1 = objExcelApp.Cells(2, 2).Value

objExcelApp.ActiveWorkbook.Save

objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing

End Sub
Jeovane
Posts: 1
Joined: Wed Jun 24, 2020 3:37 pm

Re: VBA with Citect SCADA - Reports exel

Post by Jeovane »

morbiusmn, to read from excel to Citect it worked, but if I try to write down from citect to excel it does not work. Do you know why?
morbiusmn
Posts: 9
Joined: Wed Oct 02, 2013 6:43 pm

Re: VBA with Citect SCADA - Reports exel

Post by morbiusmn »

Jeovane, Can you show me your code?
morbiusmn
Posts: 9
Joined: Wed Oct 02, 2013 6:43 pm

Re: VBA with Citect SCADA - Reports exel

Post by morbiusmn »

Jeovane wrote: Wed Jun 24, 2020 3:42 pm morbiusmn, to read from excel to Citect it worked, but if I try to write down from citect to excel it does not work. Do you know why?
Can you tell me if you used the first or the second script?