Full Version: VBA Macros
From: Carl (CSEWELL) [#15]
1 Jul 2006
To: Shaddy [#14] 1 Jul 2006
Thank you! That's the type of input I was looking for.
No code is perfect. Look at Microsoft and all the patches that they release. And those are professionals! The person that attempts to develop totally foolproof code is a fool! Okay, not totally true, but there are limitations to everything. For something like this, a lot of error checking may not be critical, or maybe others might be willing to contribute to the code.
I've been to the Oberon VBA forum, but haven't joined or spent much time there. I was hoping there would be something more specific to the engraving industry.
I was hoping to open a line of dialogue to see if this was something we, as a group, thought was important to tackle. And, more importantly, if CorelDraw VBA was stable enough between versions to make it worthwhile. The one macro I wrote that another user tried in X3 which forced them to do a system restore scares me. If CorelDraw VBA is that unstable, then developing macros might not be a good idea. Then again, if we tend to hang onto versions of CorelDraw forever, it might be beneficial.
And because of the presumed instability, I'd hate to release a macro that caused people to have to do a system restore. Are you willing to take that risk? What version of Corel are you using? Are you comfortable working with GMS files and creating command buttons for macros?
EDITED: 1 Jul 2006 by CSEWELL
From: Shaddy [#16]
1 Jul 2006
To: Carl (CSEWELL) [#15] 1 Jul 2006
I've had to restart before, but system restore? I wouldn't have thought that possible either. Maybe upping that code to Oberon and have that Alex guy look at it. He's very aware of the differences.
I have 12 on one machine, and X3 on the other, so far mine have ported over, but I didn't do anything too extreme.
I tend to stay with using the editor, I've only made one GMS file.
Buttons, I've added macros to the Global GMS and then added custom buttons to access them. Putting them in a custom GMS would probably be better, but I tend to take the easy way out and if just cut-n-paste works I'll probably do that.
I'll play with some macros and post them. Do you think GMS would be best for that?
Shaddy
From: Dave Jones (DAVERJ) [#17]
1 Jul 2006
To: Shaddy [#16] 1 Jul 2006
I don't agree. I haven't tried the CD VBA (my 1st version of CD and only had it 2 months), but I've written VBA code in other programs. It is an easy programming language that most people could learn enough to do some simple things. But it is still a programming language and if you've never written any code in any language then you would be lost as to where to start. So most people wouldn't even try.
Since I've only used CD for a couple of months, I'm still learning what features it does have, and haven't started thinking about what it doesn't do that I would use VBA to add to it.
Something else to consider is that often when people write scripts/macros/VBA to automate something they need to do, they don't write it in a generic enough form that it would be of use for a range of other people. People don't all have the same workflow. Plus when somebody slaps together a script they often stick constants in that should be variables with controls if it were a generic script for others to use.
My guess is that if we discuss some of what people find tedious and repetitive in CD, that those who know how to write VBA might be able to slap something together to help. After a few of those, some more people might get the idea of the power VBA could add and might take a shot at learning to write something themselves.
EDITED: 1 Jul 2006 by DAVERJ
From: Carl (CSEWELL) [#18]
1 Jul 2006
To: Dave Jones (DAVERJ) [#17] 1 Jul 2006
Carl: You don't have to be a programmer to use VBA
Dave: I don't agree.
Use VBA, as in use VBA macros, not use as in write VBA macros.
If you are referring to the usability of the macros, yes, some macros may not be usable for people that don't know VB. It all depends on the macro. For example, in my XYCopy macro, the user is presented with a form for entering the X-distance, Y-distance, number of rows, and number of columns. If the user hasn't selected something before running the macro, a message box will tell them so. Is that generic enough? Yes, the macro has some rudimentary error checking, like verifying that numbers (not text) are entered. It even has an undo command. It doesn't save the user-entered values (I think you have to store them in the registry!) when you re-execute the macro. And the focus remains with the form so you can't do anything else until you exit the macro.
If the macros are documented (abundant comments) even hard-coded items could be more easily changed than creating a whole new macro. All of this assumes that people will take the time to do a good (not necessarily excellent) job with the macros.
Other macros may not require any user interface, they may just perform a function: turn off all layers except the current layer, turn on all layers, move selected objects to the current layer, save the current file as version 9 and add the suffix "-v9" to the base filename.
I wouldn't wish VB on anyone and certainly not anyone that hasn't had substantial programming experience. I find it extremely difficult and tedious.
Thanks!
From: Dave Jones (DAVERJ) [#19]
1 Jul 2006
To: Carl (CSEWELL) [#18] 1 Jul 2006
Sorry, I thought you were saying anybody could write one.
As Emilly Litella (Gilda Radner) used to say: "Nevermind". :D
From: Harvey only (HARVEY-ONLY) [#20]
1 Jul 2006
To: Dave Jones (DAVERJ) [#19] 1 Jul 2006
Darn: Meant to post to ALL
This may be the place to find out what macros engravers might need. Cannot think of a better one.
EDITED: 1 Jul 2006 by HARVEY-ONLY
From: Carl (CSEWELL) [#21]
1 Jul 2006
To: Dave Jones (DAVERJ) [#19] 1 Jul 2006
No! You made some excellent points: all relevant and right on the money.
From: Shaddy [#22]
1 Jul 2006
To: Carl (CSEWELL) [#21] 1 Jul 2006
After the holiday break, I'll purdy up the macro for adding text to different objects as a replacement to the print merge. Well, not a replacement, Print merge is a powerful feature. Maybe it's more of a supplement.
There's a few macros that support this funtion that coule probably be applied to different processes. One is a macro that changes the "name" of an object of everything selected (the name that you can see in the object manager). That makes it easier for VBA to be selective on the things it alters. Such as, on a name badge you could have a generic company name called "Company", and a personalized name called "Name" or whatever makes sense to you. Then my code can more easily either change all the company names to the next company you make for, or go out and look at your list of names to fill in the other boxes with (sizing font accordingly for longer names).
Looking forward to seeing where this goes. Might even warrant a new folder here :D
Shaddy
From: UncleSteve [#23]
1 Jul 2006
To: Shaddy [#22] 2 Jul 2006
(Are you reading this, David?)
From: Carl (CSEWELL) [#24]
1 Jul 2006
To: Shaddy [#22] 2 Jul 2006
I completed a beta version of the print merge last night. It reads from a hard-coded text filename (temporary only!), copies the selected text and replaces the first word (of the selected text) with the name (one per line) in the text file. The copying is an extension of the XYCopy macro. Not at all elegantly encoded, but it appears to work. It doesn't work correctly with first name and last name, just yet, because of the property I selected to make the replacement. There's probably a better way. It might be easier to use a 'FIELD' as you suggested, but that might be too involved for a novice user to set up.
We'll have to get David to pony up some development funds. ;^)
From: Stunt Engraver (DGL) [#25]
2 Jul 2006
To: Carl (CSEWELL) [#24] 2 Jul 2006
Carl,
I've been following this thread with extreme interest. I don't want to create a stir by mentioning the dreaded "P" word, but these are exactly the types of projects I want to fund.
From: Carl (CSEWELL) [#26]
2 Jul 2006
To: Stunt Engraver (DGL) [#25] 2 Jul 2006
There are also VB protection schemes. One I've used on my CreateADMx software and it seems to work pretty good. It's based on a 2-key pair. One key is generated at the installation site and the liberation is returned based on the first key. Sounds complicated, but it's fairly easy to implement. I'm not sure how well it would play for CorelDraw macros.
I guess I'd rather see the code released for further development, but we'll see how it plays out. There may only be a few macros that would beneficial to the engraving industry.
From: Stunt Engraver (DGL) [#27]
2 Jul 2006
To: Carl (CSEWELL) [#26] 2 Jul 2006
I wasn't so concerned about the "security" of the macros as much as having something developed for the betterment of the engraving industry.
If that can be achieved through volunteerism, fine.
If, as you suggest, a financial incentive would spur things along and increase the quality of the end result (which is often the case) I'm for that as well.
Message 4230.28 was deleted
From: Carl (CSEWELL) [#29]
2 Jul 2006
To: Stunt Engraver (DGL) [#27] 2 Jul 2006
I don't need fame. I can always use more money! Maybe we'll get a REAL programmer to step up to the challenge?!?!?
Do we need to halt development until the P-word site comes online? ;^)
EDITED: 2 Jul 2006 by CSEWELL
From: Stunt Engraver (DGL) [#30]
2 Jul 2006
To: Carl (CSEWELL) [#29] 2 Jul 2006
You said the "P" word.
It's a bad word, depending on which direction the "P" is heading. :-)
My generosity will be limited, until we take that step. >.<
From: sprinter [#31]
2 Jul 2006
To: ALL
From: Carl (CSEWELL) [#32]
2 Jul 2006
To: sprinter [#31] 2 Jul 2006
I happen to use several macros and will definitely use more since my 'style' is based on my many years of using advanced CAD programs and relying on the advanced features that they have. Every shortcut that I can take, even if it takes significant time to develop, has the potential to make me more profitable and improve the service, quality, and accuracy to my customers.
Starting VBA macros in CorelDraw can be as simple as any other CorelDraw command or tool. They can be added to toolbars in just a few seconds. I have a flyout that has just macros with their own icon that makes them easy for me to run. It would be a good idea to export your workspace so it can be easily(?) restored should a problem develop.
I wouldn't recommend anyone embarking on learning VBA just for CorelDraw. I think the learning curve would be far too steep for most people that don't have a programming background. Then again, some people might enjoy the challenge.
I do believe that there is potential for even inexperienced users to take advantage of existing VBA macros, even it is only one or two. And that may not be enough for most people to mess with them. So far, the one that people believe to be the best candidate is an alternative for 'print merge'. Are there any others?
From: Carl (CSEWELL) [#33]
2 Jul 2006
To: Stunt Engraver (DGL) [#30] 2 Jul 2006
So very, very sorry. I'll try to be a better engraver and mind my "Ps" and "Qs".
{Am I banished forever, or just for a probationary period? I edited my post. Does that lessen the sentence?}
From: Stunt Engraver (DGL) [#34]
2 Jul 2006
To: Carl (CSEWELL) [#33] 2 Jul 2006
I'm feeling benevolent today. No time-outs. :P