Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Programmaticlly sign and password protect a VBA Project in Excel 2

Hi

I have a workbook that has a vba project attached which is signed and
password protected.

In this workbook I've created a sub that creates a new workbook (by moving a
worksheet to a new workbook) adds code to its "ThisWorkBook" module
(basically to unprotect, process data and protect the worksheet when a user
makes changes to a specific range).Thus this code contains passwords to
protect and unprotect a worksheet which I don't want any of my users to view
if they open the VBA editor.

I need to be able to programmatically password protect the newly created
workbook's vba project and add the original workbook's signature to it to
enable macro functionality on it.

Could someone please advise on how I go about this as I am baffled.

--
Rocco Coetzee
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Programmaticlly sign and password protect a VBA Project in Excel 2

Excel doesn't give developers this feature--if it did, then any workbook's
project could be easily cracked.

If your code is really in the ThisWorkbook module, then I'd create a template
file with that code already in it. And that workbook's project would be
protected.

Then instead of creating a new workbook with:

set newwkbk = workbooks.add(1)
or
worksheets("somesheet").copy 'to a new workbook

I'd use:
set newwkbk = workbooks.add(Template:="C:\yourpath\yourtemplatef ile.xlt")
worksheets("somesheet").copy _
after:=newwkbk.worksheets(1)
application.displayalerts = false
newwkbk.worksheets("DeleteMeLater").delete
application.displayalerts = true

(Yes, DeleteMeLater is a dummy sheet in that template workbook.)



RoccoCoetzee wrote:

Hi

I have a workbook that has a vba project attached which is signed and
password protected.

In this workbook I've created a sub that creates a new workbook (by moving a
worksheet to a new workbook) adds code to its "ThisWorkBook" module
(basically to unprotect, process data and protect the worksheet when a user
makes changes to a specific range).Thus this code contains passwords to
protect and unprotect a worksheet which I don't want any of my users to view
if they open the VBA editor.

I need to be able to programmatically password protect the newly created
workbook's vba project and add the original workbook's signature to it to
enable macro functionality on it.

Could someone please advise on how I go about this as I am baffled.

--
Rocco Coetzee


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Programmaticlly sign and password protect a VBA Project in Exc

Dave thank you for responding.

I think your solution would definitely resolve my problem.

Thank you again.

Just to satisfy my curiosity... I have stumbled on to some code someone has
written that can actually unlock vba project code programmatically (JB
VBAProject Unlocker v1.07.xls).

He is using kernel32.dll and users32.dll alias "SendMessageA".
His code looks extremely complicated but it seems he is capturing the
password dialog box with a window handle "hWnd" and entering a password which
the calling sub supplies.

Would it then also be possible to capture the vba project's "Project
Properties dialog box" with a window handle then enter Password and enter
Confirm Password in the same manner?

--
Rocco Coetzee


"Dave Peterson" wrote:

Excel doesn't give developers this feature--if it did, then any workbook's
project could be easily cracked.

If your code is really in the ThisWorkbook module, then I'd create a template
file with that code already in it. And that workbook's project would be
protected.

Then instead of creating a new workbook with:

set newwkbk = workbooks.add(1)
or
worksheets("somesheet").copy 'to a new workbook

I'd use:
set newwkbk = workbooks.add(Template:="C:\yourpath\yourtemplatef ile.xlt")
worksheets("somesheet").copy _
after:=newwkbk.worksheets(1)
application.displayalerts = false
newwkbk.worksheets("DeleteMeLater").delete
application.displayalerts = true

(Yes, DeleteMeLater is a dummy sheet in that template workbook.)



RoccoCoetzee wrote:

Hi

I have a workbook that has a vba project attached which is signed and
password protected.

In this workbook I've created a sub that creates a new workbook (by moving a
worksheet to a new workbook) adds code to its "ThisWorkBook" module
(basically to unprotect, process data and protect the worksheet when a user
makes changes to a specific range).Thus this code contains passwords to
protect and unprotect a worksheet which I don't want any of my users to view
if they open the VBA editor.

I need to be able to programmatically password protect the newly created
workbook's vba project and add the original workbook's signature to it to
enable macro functionality on it.

Could someone please advise on how I go about this as I am baffled.

--
Rocco Coetzee


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Programmaticlly sign and password protect a VBA Project in Exc

I wouldn't be surprised if that code used Sendkeys. That means that everything
must go right for it to work. If the wrong window has focus, then the sendkeys
may do something to that application--and not touch what you want at all.

I wouldn't trust Sendkeys in any application that I wasn't watching closely each
time I used it.

RoccoCoetzee wrote:

Dave thank you for responding.

I think your solution would definitely resolve my problem.

Thank you again.

Just to satisfy my curiosity... I have stumbled on to some code someone has
written that can actually unlock vba project code programmatically (JB
VBAProject Unlocker v1.07.xls).

He is using kernel32.dll and users32.dll alias "SendMessageA".
His code looks extremely complicated but it seems he is capturing the
password dialog box with a window handle "hWnd" and entering a password which
the calling sub supplies.

Would it then also be possible to capture the vba project's "Project
Properties dialog box" with a window handle then enter Password and enter
Confirm Password in the same manner?

--
Rocco Coetzee

"Dave Peterson" wrote:

Excel doesn't give developers this feature--if it did, then any workbook's
project could be easily cracked.

If your code is really in the ThisWorkbook module, then I'd create a template
file with that code already in it. And that workbook's project would be
protected.

Then instead of creating a new workbook with:

set newwkbk = workbooks.add(1)
or
worksheets("somesheet").copy 'to a new workbook

I'd use:
set newwkbk = workbooks.add(Template:="C:\yourpath\yourtemplatef ile.xlt")
worksheets("somesheet").copy _
after:=newwkbk.worksheets(1)
application.displayalerts = false
newwkbk.worksheets("DeleteMeLater").delete
application.displayalerts = true

(Yes, DeleteMeLater is a dummy sheet in that template workbook.)



RoccoCoetzee wrote:

Hi

I have a workbook that has a vba project attached which is signed and
password protected.

In this workbook I've created a sub that creates a new workbook (by moving a
worksheet to a new workbook) adds code to its "ThisWorkBook" module
(basically to unprotect, process data and protect the worksheet when a user
makes changes to a specific range).Thus this code contains passwords to
protect and unprotect a worksheet which I don't want any of my users to view
if they open the VBA editor.

I need to be able to programmatically password protect the newly created
workbook's vba project and add the original workbook's signature to it to
enable macro functionality on it.

Could someone please advise on how I go about this as I am baffled.

--
Rocco Coetzee


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Programmaticlly sign and password protect a VBA Project in Exc

I'll take your word for it.

I have done what you sugested and works like a dream.

Thanks Dave.
--
Rocco Coetzee


"Dave Peterson" wrote:

I wouldn't be surprised if that code used Sendkeys. That means that everything
must go right for it to work. If the wrong window has focus, then the sendkeys
may do something to that application--and not touch what you want at all.

I wouldn't trust Sendkeys in any application that I wasn't watching closely each
time I used it.

RoccoCoetzee wrote:

Dave thank you for responding.

I think your solution would definitely resolve my problem.

Thank you again.

Just to satisfy my curiosity... I have stumbled on to some code someone has
written that can actually unlock vba project code programmatically (JB
VBAProject Unlocker v1.07.xls).

He is using kernel32.dll and users32.dll alias "SendMessageA".
His code looks extremely complicated but it seems he is capturing the
password dialog box with a window handle "hWnd" and entering a password which
the calling sub supplies.

Would it then also be possible to capture the vba project's "Project
Properties dialog box" with a window handle then enter Password and enter
Confirm Password in the same manner?

--
Rocco Coetzee

"Dave Peterson" wrote:

Excel doesn't give developers this feature--if it did, then any workbook's
project could be easily cracked.

If your code is really in the ThisWorkbook module, then I'd create a template
file with that code already in it. And that workbook's project would be
protected.

Then instead of creating a new workbook with:

set newwkbk = workbooks.add(1)
or
worksheets("somesheet").copy 'to a new workbook

I'd use:
set newwkbk = workbooks.add(Template:="C:\yourpath\yourtemplatef ile.xlt")
worksheets("somesheet").copy _
after:=newwkbk.worksheets(1)
application.displayalerts = false
newwkbk.worksheets("DeleteMeLater").delete
application.displayalerts = true

(Yes, DeleteMeLater is a dummy sheet in that template workbook.)



RoccoCoetzee wrote:

Hi

I have a workbook that has a vba project attached which is signed and
password protected.

In this workbook I've created a sub that creates a new workbook (by moving a
worksheet to a new workbook) adds code to its "ThisWorkBook" module
(basically to unprotect, process data and protect the worksheet when a user
makes changes to a specific range).Thus this code contains passwords to
protect and unprotect a worksheet which I don't want any of my users to view
if they open the VBA editor.

I need to be able to programmatically password protect the newly created
workbook's vba project and add the original workbook's signature to it to
enable macro functionality on it.

Could someone please advise on how I go about this as I am baffled.

--
Rocco Coetzee

--

Dave Peterson


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007's VBA Project password security Greg Lovern Excel Programming 1 July 19th 08 12:58 AM
Cant Digitally Sign Excel VBA Project Stevie_J_D Excel Programming 2 November 9th 07 03:09 PM
VBA project password for builtin Excel templates survivor999 Excel Programming 3 May 6th 05 05:03 PM
password protect project with VBA code PaulM Excel Programming 1 January 26th 05 01:52 AM
Accesing vba project from wb that has vba project password protected cassidyr1 Excel Programming 2 July 3rd 04 01:49 PM


All times are GMT +1. The time now is 07:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"