vba microsoft word protect code

L

Lyes

I have created an application using VBA in MS Word and I would like to know
if there is a better way to protect the code in addition to the password
which is vulnirable to freely available tools on the web.

Thank you in advance.
 
J

Jean-Guy Marcil

Lyes was telling us:
Lyes nous racontait que :
I have created an application using VBA in MS Word and I would like
to know if there is a better way to protect the code in addition to
the password which is vulnirable to freely available tools on the web.

Yes, you can create a dll add-in with Visual Studio. But that is a lot of
work for just a template, if that is the case.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
N

natric

[Posted to microsoft.public.word.vba.general, copy sent to author]

no- said:
Lyes was telling us:
Lyes nous racontait que :


Yes, you can create a dll add-in with Visual Studio. But that is a lot of
work for just a template, if that is the case.

It's a fact that VBA code protection provided by MS itself is a funny
thing... And that it's a real problem to produce dot-based app-like when
you don't want to play in the open-source area.

However, it's also a subject on which I'm grandly interested : if
someone a day found a real way, just push me a double email with all
text in CAPS and red (to be sure) ;-)

Well : DLL ! But there's always a way to strip out all DLL calls and, by
that way, workaround the "protection"... Unless if the full app itself
is a DLL and VBA part only a kind of "launcher"...
 
J

Jonathan West

Well : DLL ! But there's always a way to strip out all DLL calls and, by
that way, workaround the "protection"... Unless if the full app itself
is a DLL and VBA part only a kind of "launcher"...

Broadly that is the approach. The template contains the UI - the toolbars
etc, and a set of macros, each of which does little more than make a call to
the DLL.
 
N

natric

[Posted to microsoft.public.word.vba.general, copy sent to author]

Broadly that is the approach. The template contains the UI - the toolbars
etc, and a set of macros, each of which does little more than make a call to
the DLL.

Yes, it's fact, but admit that using this way is mainly a workaround due
to the lack of real protection on the VBA side. Said otherwise, it's not
a true VBA protection, but rather a way to move valuable code outside of
VBA area. Not any other way, but it's a pity.
 
L

Lyes

Dear All,

Thank you for all your replies. I would say that I agree with all of your
comments. However, I have just two questions:
1. "Why shoudl I invest in additioal software if MS cannot handle the
protection of my codes in the VBA environment?"
2. "Why do I have to re-program my codes to make a dll?"

Thanks again, I would let you know if I find something new on the subject.
 
H

Howard Kaikow

Ayup, here's a module in my Normal template. All real code is in a DLL.

Option Explicit
Public clsWordVBNormal As WordVBNormal

Public Sub AutoClose()
clsWordVBNormal.AutoClose
End Sub

Public Sub AutoExec()
' Runs only when global
SetupClass
clsWordVBNormal.AutoExec
End Sub

Public Sub AutoExit()
clsWordVBNormal.AutoExit
End Sub

Public Sub AutoNew()
SetupClass
clsWordVBNormal.AutoNew
End Sub

Public Sub AutoOpen()
SetupClass
clsWordVBNormal.AutoOpen
End Sub

Private Sub SetupClass()
Dim docTemp As Word.Document
If clsWordVBNormal Is Nothing Then
If Documents.Count = 0 Then
Set docTemp = Documents.Add(Visible:=vbFalse)
End If
Set clsWordVBNormal = New WordVBNormal
clsWordVBNormal.SetClass Word.Application
If Not (docTemp Is Nothing) Then
docTemp.Close
Set docTemp = Nothing
End If
End If
End Sub
 
H

Howard Kaikow

Lyes said:
Dear All,

Thank you for all your replies. I would say that I agree with all of your
comments. However, I have just two questions:
1. "Why shoudl I invest in additioal software if MS cannot handle the
protection of my codes in the VBA environment?"

Because the value of your software is a lot more than the cost of purchasing
VB 6.
If not, then the software is not worth protecting.

Often the code will execute faster.
2. "Why do I have to re-program my codes to make a dll?"
The step is to reprogram your code within VBA to use classes, then move the
classes to VB 6.
Depending on what your code does, there may not be many changes needed to
move to VB 6.

In my case, I have gone all the way, and converted VBA Userforms to VB
Forms.
This furthers protects the code and, I am expecting, will ease the
perversion, ooops, I mean conversion from VB to VB .NET and windoze forms.
 
L

Lyes

Hi Howard,

Thanks for your explanations.

I have no doubts that it is the best way to protect my codes. However, I am
not happy by the fact that I need to do additional work because of a whole in
the protection of the macros. Why can’t they just add compiling capabilities
to VBA as it used to be in older versions of Word. Anyway, I do not have the
choice, hand me over the whip or the belt (what did you use?) .

Thanks.
 
J

Jonathan West

Lyes said:
Hi Howard,

Thanks for your explanations.

I have no doubts that it is the best way to protect my codes. However, I
am
not happy by the fact that I need to do additional work because of a whole
in
the protection of the macros. Why can’t they just add compiling
capabilities
to VBA as it used to be in older versions of Word. Anyway, I do not have
the
choice, hand me over the whip or the belt (what did you use?) .

There was never compiling capability in the macro language for any past
version of Word.

If anything , this problem is moving out into the world of stanalone
programs as well. Code created using Microsoft's new C# and VB.NET languages
compiles to something called IL (Intermediate language), which is then
interpreted by the runtimes that much be available on the target computer.

There are already several IL decompilers available that make a passable
attempt at converting IL back into VB.NET or C# code

You'll be OK though if you stick to using VB6.
 
L

Lyes

Hello All,

I would like to close this discussion with the following conclusions:

1. I should had asked the question before starting working on the application.
2. It seems that writing a dll would be the most appropriate solution to my
quest.
3. Learning how to create dll's would be beneficial for now and in the future.
4. I must think of the time when VBA would be ".net -ized" right now.
5. Thank you all for your kind help and support!

Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top