Solved

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

Posted on 2009-03-31
4
1,186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

630 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