Bilbo_Baggins_Esq
Registered User.
- Local time
- Today, 02:08
- Joined
- Jul 5, 2007
- Messages
- 586
HI ALL,
From an Excel Add-In (XLAM) a slightly modified version of this code will open an Excel workbook, and determine if the VBA Project is locked, capture the result as well as a few other attributes and put the results in a worksheet. Here I have pasted a trimmed down version minus the file open dialog box and writing of the results.
With very slight modification, I can also use this code to check the VBA Project for Word and PPT files as well.
However, I am working now to try and modify the code to work for the VBA Project contained within an Access database, again running inside Excel.
(I know, I'd much rather be working in Access, but it not an option right now)
Is there anybody that could help me modify the above code so I can achieve the same result for an Access database VBA Project?
I have been trying various different object types and methods and I can't seem to get it right.
I keep getting "type mismatch" errors, "Object doesn't support method" errors, "Argument not optional" errors.
all at various different points depending on what I'm trying at that time.
It seems like I was closer to success earlier today, (it was making it farther in the code), but I've pecked and checked so much, to be honest, I have no idea what my earlier code looked like.
I've searched the Object Browser and yes, I can find the VBIDE section and the vbext_pp_locked value, but there are no samples to help me out.
I've searched these forums but it doesn't look like anybody has posted on this topic before.
I've searched the internet and it is EASY to find code for checking a workbook, but zilch for an Access database.
Please, can anybody help me out here?
From an Excel Add-In (XLAM) a slightly modified version of this code will open an Excel workbook, and determine if the VBA Project is locked, capture the result as well as a few other attributes and put the results in a worksheet. Here I have pasted a trimmed down version minus the file open dialog box and writing of the results.
Code:
Sub CheckVBA()
Dim strDocPath As String
Dim docProj As Excel.Workbook
Dim vbpProj As VBIDE.VBProject
Dim Response As String
strDocPath = "C:\Workbook_Test.xls"
Set docProj = Workbooks.Open(strDocPath)
Set vbpProj = docProj.VBProject
If vbpProj.Protection = vbext_pp_locked Then
Response = strDocPath & Chr(10) & Chr(10) & "The VBA Project is locked"
Else
Response = strDocPath & Chr(10) & Chr(10) & "The VBA Project is not locked"
End If
MsgBox Response
ActiveWorkbook.Close (False)
End Sub
However, I am working now to try and modify the code to work for the VBA Project contained within an Access database, again running inside Excel.
(I know, I'd much rather be working in Access, but it not an option right now)
Is there anybody that could help me modify the above code so I can achieve the same result for an Access database VBA Project?
I have been trying various different object types and methods and I can't seem to get it right.
I keep getting "type mismatch" errors, "Object doesn't support method" errors, "Argument not optional" errors.
all at various different points depending on what I'm trying at that time.
It seems like I was closer to success earlier today, (it was making it farther in the code), but I've pecked and checked so much, to be honest, I have no idea what my earlier code looked like.
I've searched the Object Browser and yes, I can find the VBIDE section and the vbext_pp_locked value, but there are no samples to help me out.
I've searched these forums but it doesn't look like anybody has posted on this topic before.
I've searched the internet and it is EASY to find code for checking a workbook, but zilch for an Access database.
Please, can anybody help me out here?