Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Programmatically modifying code using VBE in a protected project

I am programmatically changing code lines to allow users to modify a
modelfunction in Excel:

So I use the VBE like:


ThisWorkbook.VBProject.VBComponents("Maincode").Co deModule.ReplaceLine 6,
CodeLine

Does anyone know how to do this and still lock the project for viewing
using a password?

Thanks!
Alex van der Spek
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Programmatically modifying code using VBE in a protected project

I'm not aware that you can programmatically lock a project. Think about it,
that could be a very slippery slope if locked projects can be unlocked
programmatically.
--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"Alex van der Spek" wrote:

I am programmatically changing code lines to allow users to modify a
modelfunction in Excel:

So I use the VBE like:


ThisWorkbook.VBProject.VBComponents("Maincode").Co deModule.ReplaceLine 6,
CodeLine

Does anyone know how to do this and still lock the project for viewing
using a password?

Thanks!
Alex van der Spek

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Programmatically modifying code using VBE in a protected project

Coding against the VBE and password protection do not get along. Your only
option involves using send keys which is hit and miss... Check out this
link...

http://www.cpearson.com/excel/vbe.aspx
Specifically
The VBA Project that you are going to change with these procedures must be
unlocked. There is no programmatic way to unlock a VBA project (other than
using SendKeys). If the project is locked, you must manually unlock.
Otherwise, the procedures will not work.
--
HTH...

Jim Thomlinson


"Alex van der Spek" wrote:

I am programmatically changing code lines to allow users to modify a
modelfunction in Excel:

So I use the VBE like:


ThisWorkbook.VBProject.VBComponents("Maincode").Co deModule.ReplaceLine 6,
CodeLine

Does anyone know how to do this and still lock the project for viewing
using a password?

Thanks!
Alex van der Spek

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Programmatically modifying code using VBE in a protected proje

Hi Jim,

I've not used Send Keys and would prefer not to, but why is it's use
problematic?

Thanks,
Barb Reinhardt

"Jim Thomlinson" wrote:

Coding against the VBE and password protection do not get along. Your only
option involves using send keys which is hit and miss... Check out this
link...

http://www.cpearson.com/excel/vbe.aspx
Specifically
The VBA Project that you are going to change with these procedures must be
unlocked. There is no programmatic way to unlock a VBA project (other than
using SendKeys). If the project is locked, you must manually unlock.
Otherwise, the procedures will not work.
--
HTH...

Jim Thomlinson


"Alex van der Spek" wrote:

I am programmatically changing code lines to allow users to modify a
modelfunction in Excel:

So I use the VBE like:


ThisWorkbook.VBProject.VBComponents("Maincode").Co deModule.ReplaceLine 6,
CodeLine

Does anyone know how to do this and still lock the project for viewing
using a password?

Thanks!
Alex van der Spek

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Programmatically modifying code using VBE in a protected project

I had not thought of using SendKeys myself. That should work, but it is
cumbersome indeed.

How about splitting the code in two parts:

1. One locked project stored in an Add-in. This project contains the main
code including the bit that manipulates the VBE.
2. One unlocked file, the user front end. This project contains the one
line of code that should be modified at the user's wish (updating a model
function). The modification, however is done by the locked project which
contains the VBE manipulation code.

Would that work?

Thanks!
Alex van der Spek



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
Programmatically unprotect my protected project to delete modules? Toby Erkson Excel Programming 3 December 13th 06 05:52 PM
Code Sign PW Protected Project? Walt Weber[_2_] Excel Programming 1 February 26th 05 01:27 AM
Programmatically delete macro using a protected project John Cole, Jr. Excel Programming 1 November 14th 04 04:22 PM
Assigning the Help 4, *.HLP file for a project programmatically in a protected Project Tony Seiscons Excel Programming 0 October 4th 04 03:10 PM
replace line of code in vba protected project Konrad[_5_] Excel Programming 0 November 26th 03 08:27 PM


All times are GMT +1. The time now is 06:33 PM.

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

About Us

"It's about Microsoft Excel"