Page 1 of 1
VBA with Citect SCADA - Reports exel
Posted: Tue Apr 19, 2016 8:28 am
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
I will send one key Citect 7.5 crack
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
////////////////////
Re: VBA with Citect SCADA - Reports exel
Posted: Tue Apr 19, 2016 8:37 am
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
Re: VBA with Citect SCADA - Reports exel
Posted: Wed Apr 20, 2016 2:59 am
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
I will send one key Citect 7.5 crack
code://///////////////////
Sub WriteToExcelFile()
Dim objExcelApp As Object
Help
help
someone help me with the code above runs ok
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
Re: VBA with Citect SCADA - Reports exel
Posted: Fri Apr 22, 2016 7:52 am
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..
Re: VBA with Citect SCADA - Reports exel
Posted: Fri Apr 22, 2016 9:08 am
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
Re: VBA with Citect SCADA - Reports exel
Posted: Fri Apr 22, 2016 9:21 am
by daocongdabl
help
help
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=
[/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
Re: VBA with Citect SCADA - Reports exel
Posted: Sun Apr 24, 2016 9:15 am
by PCNightmare
Maybe need to read tag1 value into a string???
Dim sTag as string;
sTag=tagread("tag1");
objExcelApp.Cells(2, 2).Value=sTag;
Re: VBA with Citect SCADA - Reports exel
Posted: Fri Jan 26, 2018 5:48 pm
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
Re: VBA with Citect SCADA - Reports exel
Posted: Fri Feb 23, 2018 9:54 pm
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)
Re: VBA with Citect SCADA - Reports exel
Posted: Mon Mar 05, 2018 5:49 pm
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
Re: VBA with Citect SCADA - Reports exel
Posted: Wed Jun 24, 2020 3:42 pm
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?
Re: VBA with Citect SCADA - Reports exel
Posted: Wed Jul 29, 2020 6:43 pm
by morbiusmn
Jeovane, Can you show me your code?
Re: VBA with Citect SCADA - Reports exel
Posted: Mon Aug 17, 2020 4:14 pm
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?