programming vba in vb

  • Thread starter Thread starter AAAAA
  • Start date Start date
A

AAAAA

Hi

I would like to know if it is possible to program my VBA code in VB.
For example I want to prgram something in range("a1"), but I want to do it
in VB and not in VBA. I want to do this for security purposes as Excel is
easy to crack.

Any solutions will be helpful.

Regards

Anthony
 
Anthony,

You can write your code as an ActiveX DLL callable by VBA
procedures, or you can write a COM Add-In, which too is an
ActiveX DLL that supports a special interface. Neither of these
approaches is trivial, but neither is terribly difficult if you
have a proficiency in VB programming.

You can't simply create an exe out of your VBA code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Yes, you can create an exe out of your VBA code.

I'm now doing it all the time in VB6. I've deleted my VBA
programs at work on my hard drive, and now just use these
executables that I created at home (of the VBA code). Bob
Phillips and others gave me some clues, and now it's
easy. Once you figure it out, you just call the specially
written subroutine in front of every VBA action. It's
flawless.

I suppose the next thing for me to do, is to learn about
writing the code as an ActiveX DLL. Care to share how
it's being done? I'd supply you with some "teasing" code,
but I'm at work and all this other code is at home.

Merry Christmas and Happy Holidays!!!
 
Writing an activex.dll takes a little getting used to, but there is
plenty of help available. What you need to learn, mostly, is how to
create class modules. If you already know how to do that, all you need
to do is select the type of application to create when you start.

The most important part of writing class modules is the use of
properties, most of which should be "public" to be of any use. There
are two type of "procedures" that are used, a property "let" (which sets
the value of a private variable) and a property "get" (which retrieves
this value). You need to use a property "set" instead of a "let" if the
property is an object type.

A very much simplified class module might contain the following (note
that I am writing this from a friend's computer, without syntax
checking, so use it with care):

Private m_Color as integer

Public Property Get Color() as Integer
Color = m_Color

End Property

Public Property Let Color(ByVal vNewVal as Integer)
m_Color = vNewVal

End Property

If the above code was in a class module called "Crayon", you could use
it in an application like this, after compiling the DLL and setting a
reference to that file:

Dim xCrayon as New Crayon
Dim Xcolor as Integer

xCrayon.Color = 4 ' This executes the property "set"
Xcolor = xCrayon.Color ' Executes the property "get"

You can also use enums to set integer values to string constants.

Hope this helps, and happy holiday!!

Martin
 
Back
Top