Solved

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

Posted on 2009-03-31
4
1,080 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

860 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