Using VB graphics commands in VBA
Using VB graphics commands in VBA
(OP)
I am attempting to use the graphics commands/methods described in Rod Stephens "Visual Basic Graphics Programming" in VBA with Excel. I'm hoping to be able to add a graphics window that shows the relative positions and orientations of a couple of rectangles that represent two colliding vehicles. The positions and orientations are based on data listed on Sheet1 of an Excel workbook.
In an attempt to get my feet wet, I created a new module in the VB Editor and borrowed some simple code from the book that draws a rectangle using the Line command after changing the scale using the ScaleX and ScaleY commands. Excel/VBA did not like the Scale commands but did not seem to mind the Line command.
So I commented out the ScaleX/Y commands and filled numbers directly in the Line command. The code executes successfully (at least no errors) but I never get a window that opens up to display the rectangle.
'wid = ScaleX(5, vbPixels, ScaleMode)
'hgt = ScaleY(5, vbPixels, ScaleMode)
wid = 50
hgt = 50
Line (10, 10)-Step(wid, hgt), vbRed, BF
Am I missing something in the availability of the VB commands in VBA? Shouldn't I have all of VB available to me?
Maybe this is so simple that I'm just missing the boat on this? I am a novice at the graphics part of the VBA development, but have done a bit of programming in VBA .
I am running Excel 2003 on a Vista desktop.
I appreciate and help.
In an attempt to get my feet wet, I created a new module in the VB Editor and borrowed some simple code from the book that draws a rectangle using the Line command after changing the scale using the ScaleX and ScaleY commands. Excel/VBA did not like the Scale commands but did not seem to mind the Line command.
So I commented out the ScaleX/Y commands and filled numbers directly in the Line command. The code executes successfully (at least no errors) but I never get a window that opens up to display the rectangle.
'wid = ScaleX(5, vbPixels, ScaleMode)
'hgt = ScaleY(5, vbPixels, ScaleMode)
wid = 50
hgt = 50
Line (10, 10)-Step(wid, hgt), vbRed, BF
Am I missing something in the availability of the VB commands in VBA? Shouldn't I have all of VB available to me?
Maybe this is so simple that I'm just missing the boat on this? I am a novice at the graphics part of the VBA development, but have done a bit of programming in VBA .
I am running Excel 2003 on a Vista desktop.
I appreciate and help.
RE: Using VB graphics commands in VBA
Also according to OReilly's VB reference, the printer object (and hence its line method) is not available in VBA.
=====================================
Eng-tips forums: The best place on the web for engineering discussions.
RE: Using VB graphics commands in VBA
=====================================
Eng-tips forums: The best place on the web for engineering discussions.
RE: Using VB graphics commands in VBA
=====================================
Eng-tips forums: The best place on the web for engineering discussions.
RE: Using VB graphics commands in VBA
VB is a standalone Windows programming language.
TTFN
FAQ731-376: Eng-Tips.com Forum Policies
RE: Using VB graphics commands in VBA
http://
The current post deals with scaling drawings in an XY chart, but I will be dealing with drawing shape objects using VBA over the coming weeks.
For your application I think using an XY chart is worth considering. The advantage is that you can get the chart updated without any VBA, and you can (if you want) have it on its own sheet. A disadvantage is you can't easily shade the shapes, and adding text, arrows etc is more difficult.
Doug Jenkins
Interactive Design Services
www.interactiveds.com.au
RE: Using VB graphics commands in VBA
However, if I would like to be a little more aggressive in the future, beyond a couple of simple rectangles, is it possible to link the full version of VB with the data in an Excel workbook to do some true animation? Maybe create an executable program in VB that accesses the data in an open Excel workbook and animates the data in some fashion. Please advise.
RE: Using VB graphics commands in VBA
I2I
RE: Using VB graphics commands in VBA
TTFN
FAQ731-376: Eng-Tips.com Forum Policies
RE: Using VB graphics commands in VBA
http://www
Glenn
RE: Using VB graphics commands in VBA
Yes, it is possible, but it is also possible, more easily, with VBA. Don't underestimate VBA (have a look at the link from geekEE.
Doug Jenkins
Interactive Design Services
www.interactiveds.com.au
RE: Using VB graphics commands in VBA
RE: Using VB graphics commands in VBA
The express editions are free and have more features than VBA. I have not messed with mine yet but I do know t hat there is a graphics object.
Just a thought.
Gerald Austin
Iuka, Mississippi
http://www.weldinginspectionsvcs.com
RE: Using VB graphics commands in VBA
I have posted a simple demonstartion of an animation in Excel, using VBA, on my blog:
http://
It's just a circle bouncing around inside a box, but it should be fairly easy to amend it to do what was wanted in the original post in this thread.
You have to dowload the file to see the animation by the way. I haven't worked out how to convert it to run on the Net yet.
Doug Jenkins
Interactive Design Services
www.interactiveds.com.au
RE: Using VB graphics commands in VBA
I would like to keep things in the VBA/Excel environment and the post at www.gamasutra.com and at newtonexcelback.com look pretty interesting.
I still welcome any additional ideas if anyone wants to post. I will continue to monitor this thread.
Thanks again.
Matt Brach
Brach Engineering
www.brachengineering.com