You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old January 27th, 2009, 05:52 AM   #1
sephiroth
Member
United Kingdom

sephiroth is offline
 
Join Date: Jan 2009
Location: Sheffield
Posts: 4
VBA Scripts on RSView SE

Hi everybody.

I'm having a problem rigth now with RSView, I need to execute periodic VBA Scripts on my application, the problem is that the VBA scripts can only be created independently for each display.

So how can I create a global script and execute it whenever I want?... for example calling it from an Event. I had seem that in RSView32 can be use a vbaExec function, it is possible to do the same in RSView SE... how????

J.J.
  Reply With Quote
Old January 27th, 2009, 10:00 AM   #2
rdrast
Lifetime Supporting Member
United States

rdrast is offline
 
rdrast's Avatar
 
Join Date: Apr 2003
Location: South Carolina Lowcountry
Posts: 5,278
Quote:
Originally Posted by sephiroth View Post
Hi everybody.

I'm having a problem rigth now with RSView, I need to execute periodic VBA Scripts on my application, the problem is that the VBA scripts can only be created independently for each display.

So how can I create a global script and execute it whenever I want?... for example calling it from an Event. I had seem that in RSView32 can be use a vbaExec function, it is possible to do the same in RSView SE... how????

J.J.
/sigh... ACH...

Okay. I'm going to try to describe this in the nutshell version, but it's a bit complicated anyway.

The best way of triggering a bit of code, is actually from the PLC. Use a bit, or analog value, or whatever. Step by Step follows, assuming you are triggering the function with a PLC bit called "Trigger".

  1. Create a dedicated window, it does not have to be pretty. Set it up as "On Top", "Cache After Displaying - YES", check off "Always Updating", "Show Last Acquired Value", and set the update rate to a relatively fast rate.
  2. Create a startup macro, to open that window with the /ZA switches. "Display _VBA_Code_Win /ZA". I also advise creating a button to close all windows, flush the cache, and then reopen "Home" windows with the above switch. The /ZA option will open the window, and keep it updating, even when it gets hidden by a 'Replace' window.
  3. On the new window, put an analog tag, pointing to the [PLC]Trigger bit, expose it to VBA, and use an OnChange event in VBA to trigger your other processing. Give it a name, such as "nd_TriggerDisp". NOTE: Generally, in the VBA for the window, you will first want to create a global tag array, and populate it with your trigger bit, so you can reset it:
In Global Declarations:

Dim GlobalGroup as TagGroup
Dim TagGlobal as Tag
Dim TagsInError as StringList

In DisplayLoad:
if GlobalGroup is Nothing Then
Set GlobalGroup = Application.CreateTagGroup(Me.AreaName, 500)
GlobalGroup.Add "{[PLC]Trigger}"

In your nd_TriggerDisp_Change() event for your tag on the window:

If nd_TriggerDisp.Value = 1 then
(Process your special VBA Code)

' Reset the tag in the PLC to indicate processing complete:
Set TagGlobal = GlobalGroup.Item({[PLC]Trigger])
TagGlobal.PendingWriteValue = 0
GlobalGroup.WritePendingValues(TagsInError)
End If
End Sub



That's it in a nutshell. Of course, you probably want to add other guarding in the VBA to ensure that this code doesn't get executed by every client. Use the computer name to determine which client should process the code.

Also, be sure to use full error checking in each routine, unlike the example above.

Good luck.
__________________
------------------------------------
How to ask questions the SMART Way!

Look First, Ask Second!

  Reply With Quote
Old January 28th, 2009, 07:07 AM   #3
sephiroth
Member
United Kingdom

sephiroth is offline
 
Join Date: Jan 2009
Location: Sheffield
Posts: 4
Thanks a lot for your reply.

I had the hope that i could find a less tricky solution for this, but I guess that it is not possible.

I'll try this.... thank you.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Using VBA in RSView SE question. briana banks LIVE PLC Questions And Answers 11 January 17th, 2014 07:56 AM
RSview SE, VBA & Weather fischb22 LIVE PLC Questions And Answers 1 November 27th, 2008 10:01 PM
VBA to write values from RSView SE V5.00.00 to CLX Tags MorphuisOGrady LIVE PLC Questions And Answers 0 April 24th, 2008 05:56 PM
How to get the event in VBA? RSView SE rfcard LIVE PLC Questions And Answers 0 February 25th, 2008 01:15 PM
RSView SE Globally scoped VBA? tvey LIVE PLC Questions And Answers 0 June 26th, 2007 03:07 PM


All times are GMT -5. The time now is 11:45 PM.


.