Solved

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

Posted on 2009-03-31
4
1,030 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
ID: 24032797
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
ID: 24032826
to run from vba, you can use Shell(command)
0
 

Author Comment

by:mytfein
ID: 24033446
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
ID: 24033763
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

863 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

21 Experts available now in Live!

Get 1:1 Help Now