Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-03-31
4
Medium Priority
?
1,250 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 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

721 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