YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

VBA Code for find and replace text in Process Book Options · View
nkumarko
#1 Posted : Tuesday, July 20, 2010 1:43:30 PM
Rank: Newbie
Groups: Member

Joined: 7/20/2010
Posts: 2
Location: qatar
Can any one provide VBA Code for replacing the text in Process Book Files?
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
Tommy
#2 Posted : Tuesday, July 20, 2010 7:53:22 PM
Rank: Member
Groups: Member

Joined: 7/19/2010
Posts: 20
As in replacing text in a text box?

Step 1 is to make sure all the text boxes have scripting activated (right click -> enable scripting)
Step 2 is to replace the 2 stings in the code below with what you are searching for and what you want to replace it with:
Code:
Sub ReplaceText()
For Each item in ThisDisplay.Symbols
  If item.Type = 4 Then
    item.Contents = Replace(item.contents,"String to Search For","String to add in")
  End If
Next
End Sub

(Suggestions / corrections to my coding / syntax are welcome.)
Disclaimer: Any code presented by myself might be unconventional because of the lack of formal training. Any corrections are welcome. =)
RJK Solutions
#3 Posted : Tuesday, July 20, 2010 8:29:27 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
As Tommy has touched on, it really depends on what you refer to as text. Some symbols have a "Contents" property that stores a string, other symbols can have a PI tag name, others the name of a dataset, traces on a PI trend etc. If you could clarify what text/strings you want to replace then we can help you further.
Principal Consultant
Real-Time Data Management @ Wipro Technologies
nkumarko
#4 Posted : Wednesday, July 21, 2010 6:55:05 AM
Rank: Newbie
Groups: Member

Joined: 7/20/2010
Posts: 2
Location: qatar
Tommy wrote:
As in replacing text in a text box?

Step 1 is to make sure all the text boxes have scripting activated (right click -> enable scripting)
Step 2 is to replace the 2 stings in the code below with what you are searching for and what you want to replace it with:
Code:
Sub ReplaceText()
For Each item in ThisDisplay.Symbols
  If item.Type = 4 Then
    item.Contents = Replace(item.contents,"String to Search For","String to add in")
  End If
Next
End Sub

(Suggestions / corrections to my coding / syntax are welcome.)



Thanks a lot.... this worked
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.