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

Create text/rectangle/combobox... from the VBA code Options · View
restival
#1 Posted : Friday, September 02, 2011 11:23:27 AM
Rank: Newbie
Groups: Member

Joined: 8/25/2011
Posts: 3
Hello,

I am a beginner in VBA.
I am trying to avoid creating processbooks using the mouse to automatize and standardize the creation. For the standardize part, it is going ok but I can't manage to draw object from VBA editor.
At the moment, I am creating text, ..., and rectangle objects with the mouse to then call the objects with VBA. I would like to avoid this process and create my object in modules like sub draw_rectangle(),...

I have been searching on the internet and I have found this http://msdn.microsoft.co...fzwyx%28v=vs.80%29.aspx

I can't make that :
Private Sub Form_Paint()
' Draw a solid black line 200 twips from the top of the form.
Line (0, 200) - (ScaleWidth, 200), vbBlack
End Sub

or that :
Private Sub Form1_Paint(ByVal sender As Object, ByVal e _
As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Draw a solid black line 25 pixels from the top of the form.
e.Graphics.DrawLine(Pens.Black, 0, 25, Me.Width, 25)
End Sub

work

I am using VBA 6.3
I have imported System, System_Drawing & System_Windows_Form librairies. Do I miss some librairies ?

Well, I would gladly appreciate any help.
Let me know if my explanation are not clear.

Thank you in advance,
Rémi
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.
milesUK
#2 Posted : Friday, September 02, 2011 1:28:37 PM
Rank: Advanced Member
Groups: Member

Joined: 5/28/2009
Posts: 75
Location: Cheshire, UK
Remi, I find that I have to really hunt for info in PB VBA Help however i have perseverred and come across this to create a line:

Code:
Sub CreateLine()
'PB Symbol object
Dim oLine As Line

'add a trend object to the Symbols collection
'the Add function will return a reference to the trend object

Set oLine = ThisDisplay.Symbols.Add(pbSymbolLine)

With oLine
.Name = "Line Example 1"

'define starting and ending points for the line
.Endpoints(1).x = -14950 'left
.Endpoints(1).y = 14100 'top
.Endpoints(2).x = -13700
.Endpoints(2).y = 14100

'set line color and styles
.LineColor = pbBlue
.LineStyle.Style = pbLDash
.LineStyle.Weight = pbThin

'add arrow on right.
.LineStyle.End = 3

End With

End Sub
There are other symbols/shapes including pbSymbolRectangle. Hope that puts on the right track.

regards,

Miles
MilesUK
ProcessBook v3.0.15.3
restival
#3 Posted : Friday, September 02, 2011 1:55:44 PM
Rank: Newbie
Groups: Member

Joined: 8/25/2011
Posts: 3
Thank you Miles,

I will try that right now !!!
restival
#4 Posted : Friday, September 02, 2011 2:03:40 PM
Rank: Newbie
Groups: Member

Joined: 8/25/2011
Posts: 3
work great thanks... I knew it would be obvious but I have really searched long... thanks.
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.