plcforum.uz.ua

International PLC Forum
It is currently Fri Sep 21, 2018 3:11 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Tue Apr 19, 2016 11:28 am 

Joined: Wed Jun 09, 2010 5:48 pm
Posts: 8
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
////////////////////


Top
 Profile  
 
PostPosted: Tue Apr 19, 2016 11:37 am 

Joined: Wed Jun 09, 2010 5:48 pm
Posts: 8
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


Top
 Profile  
 
PostPosted: Wed Apr 20, 2016 5:59 am 

Joined: Wed Jun 09, 2010 5:48 pm
Posts: 8
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


Top
 Profile  
 
PostPosted: Fri Apr 22, 2016 10:52 am 

Joined: Thu Feb 07, 2013 11:21 am
Posts: 4
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..


Top
 Profile  
 
PostPosted: Fri Apr 22, 2016 12:08 pm 

Joined: Wed Jun 09, 2010 5:48 pm
Posts: 8
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


Top
 Profile  
 
PostPosted: Fri Apr 22, 2016 12:21 pm 

Joined: Wed Jun 09, 2010 5:48 pm
Posts: 8
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:
[color=#FF0000]tag1.Value[/color]
////////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


Top
 Profile  
 
PostPosted: Sun Apr 24, 2016 12:15 pm 

Joined: Thu Feb 07, 2013 11:21 am
Posts: 4
Maybe need to read tag1 value into a string???

Dim sTag as string;

sTag=tagread("tag1");

objExcelApp.Cells(2, 2).Value=sTag;


Top
 Profile  
 
PostPosted: Fri Jan 26, 2018 8:48 pm 

Joined: Wed Oct 02, 2013 9:43 pm
Posts: 3
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 8:08 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sat Feb 24, 2018 12:54 am 

Joined: Wed Oct 02, 2013 9:43 pm
Posts: 3
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)


Top
 Profile  
 
PostPosted: Mon Mar 05, 2018 8:49 pm 

Joined: Wed Oct 02, 2013 9:43 pm
Posts: 3
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by International PLCforum® Forum Software © PLCforum
Mobile version