Solved

Excel file - Encrypting - is it possible to encrypt via VBA, before attaching to email?

Posted on 2009-03-31
4
996 Views
Last Modified: 2013-12-18
Hi EE,

Do you know of Encrypting software that works with VBA?

We need to encrypt Excel file before emailing to user.

Please advise with ideas/code/software vendor?

tx, sandra
0
Comment
Question by:mytfein
  • 3
4 Comments
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
You can encrypt files using WinZip. You can then call WinZip from the command line.  http://www.winzip.com/aes_info.htm
Is that a possibility for you?  

Simple way is to just set a password in the zip file. See the usage here
http://www.memecode.com/docs/winzip.html

If you want to encrypt, then I think you need the command line addon installed.
An example of usage is here in EE itself!
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_21006886.html?qid=21006886


0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
to run from vba, you can use Shell(command)
0
 

Author Comment

by:mytfein
Comment Utility
Hi Rocki,
a) thx so much for your help... and experience....

b) perhaps do you have the command already worked out for shell(command)?
     the article are a bit technical. If i got a command example, i could try to follow along
     in the articles that you emailed.

do you specify in the (command) the name of:
source file
name for zip file
so that, i can attach the zip file instead of xls file?

c) we're getting winzip pro - i'm a little unclear, but i think we have to attach extractor
(similar to Adobe reader, but for zip files), so that people can extract file - something like that...

tx, s
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
Comment Utility
No problems

Basically, lets assume you have installed Winzip and you have the command line addon (look on winzip website)

Say it was installed in C:\Program Files\WinZip90

Lets create a method to do this
Public Sub EncryptViaWinzip(ByVal sFiles As String, ByVal sWinZipFile As String)
    Shell Chr$(34) & "C:\Program Files\WinZip90\WZZIP.EXE" & Chr$(34) & " -sXXX -ycAES256 " & sWinZipFile & " " & sFiles, vbHide
End Sub

Shell tells it to run the following dos comamnd

chr$(34) is double quotes so we wrap the path of wzzip in double quotes

 Chr$(34) & "C:\Program Files\WinZip90\WZZIP.EXE" & Chr$(34)

-sXXX     Now we specify the password, example here uses XXX.  You can use whatever, even better is to pass it into the function



-ycAES256      Specifies using 256bit encryption

sWinZipFile     The name of your winzip file

sFiles              The name(s) of the files you want to zip up

Here is it again this time with password as argument

Public Sub EncryptViaWinzip(ByVal sFiles As String, ByVal sWinZipFile As String, byval sPassword as String)
    Shell Chr$(34) & "C:\Program Files\WinZip90\WZZIP.EXE" & Chr$(34) & " -s" & sPassword & " -ycAES256 " & sWinZipFile & " " & sFiles, vbHide
End Sub


Now you call it like this

    EncryptViaWinzip "c:\temp\myfileIwantzippedup.txt", "c:\temp\nameofmyzippedfile.zip", "sandra"


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now