Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protect macro and close VBE programatically


I have a macro that writes another macro programatically. Does anyone
know how to protect the VBA code and then close VBE progrmatically?


--
biosci
------------------------------------------------------------------------
biosci's Profile: http://www.excelforum.com/member.php...o&userid=32827
View this thread: http://www.excelforum.com/showthread...hreadid=531147

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Protect macro and close VBE programatically

The following line should close the VBE:
Application.VBE.MainWindow.Visible = False

As for protecting the project, I think you're stuck with using Sendkeys.
Check out Sendkeys in Help. I don't have the Help file loaded on this
machine, so the appended code example is from memory only. It appears to work
but probably could be improved.

I have commented out the last Tab and Enter ("{TAB}~") which will close the
dialog and not let you see what happens. I did the same for the line that
closes the VBE. Uncomment these in your code.

Regards,
Greg

Const pwd As String = "monkey"

Sub Test()
With Application
.SendKeys "%Te+{TAB}{Right}", True
.SendKeys "%v", True
.SendKeys "%p" & pwd, True
.SendKeys "%c" & pwd, True
'.SendKeys "{TAB}~"
'DoEvents
'.VBE.MainWindow.Visible = False
End With
End Sub


"biosci" wrote:


I have a macro that writes another macro programatically. Does anyone
know how to protect the VBA code and then close VBE progrmatically?


--
biosci
------------------------------------------------------------------------
biosci's Profile: http://www.excelforum.com/member.php...o&userid=32827
View this thread: http://www.excelforum.com/showthread...hreadid=531147


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protect macro and close VBE programatically


Thanks Greg. That worked briliiantly.


--
biosci
------------------------------------------------------------------------
biosci's Profile: http://www.excelforum.com/member.php...o&userid=32827
View this thread: http://www.excelforum.com/showthread...hreadid=531147

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
Protect cells with data on save/close AJPendragon Excel Worksheet Functions 0 November 18th 08 10:27 PM
how to setup a excel sheet to be protect after save and close file Marco Excel Discussion (Misc queries) 0 March 11th 08 10:56 PM
Can I protect a document and still open / close groups Paul Excel Worksheet Functions 1 September 25th 06 06:47 PM
Add/Run macro programatically OLE error Woody[_3_] Excel Programming 7 June 16th 05 04:14 PM
Programatically close a file without saving [email protected] Excel Programming 2 December 26th 04 01:23 AM


All times are GMT +1. The time now is 09:33 AM.

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"