Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Protect VBAProject from within the code

Is there any way to Protect/Unprotect the VBAProject from within the VB code
rather than from the VisualBasic user interface?

thanks,
ken


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Protect VBAProject from within the code

Only using sendkeys.

--
Regards,
Tom Ogilvy


"Ken Soenen" wrote in message
...
Is there any way to Protect/Unprotect the VBAProject from within the VB

code
rather than from the VisualBasic user interface?

thanks,
ken




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Protect VBAProject from within the code

You can keep the VB code from ever getting into the users workbook.
How's that?

1. Store the VB code in an AddIn,
2. In the template or workbook, the one having the numbers add subs
like these to remove the addin reference :


Private Function ReferenceExists(reference As String) As Boolean
Dim result As Boolean
result = False

On Error Resume Next
result = Not Me.VBProject.References(reference) Is Nothing

ReferenceExists = result
End Function


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If ReferenceExists("MyExcellAddin") Then
WorkbookUtils.RemoveReferences Me
End If
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Protect VBAProject from within the code

This might help too.


Private Sub Workbook_Open()
If ReferenceExists("MyExcellAddin") Then
' We need to generate the report
ReportUtils.AutoGenerateReport Me
End If
End Sub

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
Can protect worksheet then workbook but not Protect and Share in code [email protected] Excel Programming 7 January 16th 17 07:01 AM
Generic protect/unprotect code through buttons and code? StargateFanFromWork[_3_] Excel Programming 4 December 31st 05 12:10 AM
Activate code from another VBAProject MVM Excel Programming 2 November 5th 05 07:05 PM
VBAProject Protect Kevin Excel Programming 3 November 17th 03 06:50 PM
code in VBAProject will not run Mike[_58_] Excel Programming 2 November 9th 03 04:08 PM


All times are GMT +1. The time now is 04:42 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"