Forum

VBA on Protected Fo...
 
Notifications
Clear all

VBA on Protected Form Fill Document

4 Posts
2 Users
0 Reactions
97 Views
(@paul-sanft)
Posts: 35
Trusted Member
Topic starter
 

Hi,

Not sure if this can be answered as it's about Microsoft Word; but I'm sure it would run the same as excel.

 

I have a form fill document that is restricted so that they can't change the document at all; but rather just complete the necessary components. However; at the end of each block (multiple users) I have created a VBA that stamps their information by by using a command button; unfortunately because the doc is protected the VBA wont run.

 

Is there something I can add to the to each VBA to make it work?

Current VBA

 

Private Sub SuperVisor_Click()

 Selection.Font.BoldBi = 10

   Selection.Font.ColorIndex = vbBlack

   Selection.TypeText ("VBA Sign Off By") & Chr(32) & Environ("UserName") & Chr(32) & Chr(15) & Chr(32)  & _

                              Format (Date, "Long Date") & Chr(32) & Chr(150) & Chr(32) & _

                              Format (Time, "HH:MM:SS")

lbl_Exit:

   Exit Sub

End Sub

 
Posted : 27/11/2023 9:29 pm
(@keebellah)
Posts: 373
Reputable Member
 

Hi, 

I haven't tried it but maybe it works like in Excel.

You could trigger a macro that when you open the document it unprotects it and directly protects it again with the known password and add the parameter UserInterFaceOnly=True so that when the other macro is triggered it updates the fields.

Another option is to include the uprotect (with password) and after updateing protects it again

Hope my explanation makes sense

 
Posted : 29/11/2023 3:38 am
(@paul-sanft)
Posts: 35
Trusted Member
Topic starter
 

Hi Hans,

Thanks for that; and it may be a possible option but as I've been working with it I realised that I could unprotect sections (I've done this before but my old brain probaly forgot); so I should be able to place the Modules inside an unprotceted section.

 

Thanks Anyway; and you never know I may be back for more.

 

Regards 

Paul

 
Posted : 30/11/2023 1:31 pm
(@keebellah)
Posts: 373
Reputable Member
 

You know where to find us.

 
Posted : 01/12/2023 3:02 am
Share: