ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete userform/module using VB (https://www.excelbanter.com/excel-programming/271844-delete-userform-module-using-vbulletin.html)

Rohit Thomas

Delete userform/module using VB
 
Hello All,

Is it possible to delete a userform or module from an
Excel project programmatically? If it is possible, can you
provide some sample code or point me to a website where I
can find some?

Thanks,
Rohit Thomas

Chip Pearson

Delete userform/module using VB
 
Rohit,

See www.cpearson.com/excel/vbe.htm for details for this sort of
thing.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Rohit Thomas" wrote in message
...
Hello All,

Is it possible to delete a userform or module from an
Excel project programmatically? If it is possible, can you
provide some sample code or point me to a website where I
can find some?

Thanks,
Rohit Thomas




Rohit Thomas

Delete userform/module using VB
 
Chip,

Thanks for the response. I took a look at your website and
have one question....If my project is password protected,
is there code that I can run to unprotect it before
deleting the userform or module. It would need to be
protected after the useform or module is deleted.

Thanks,
Rohit
-----Original Message-----
Rohit,

See www.cpearson.com/excel/vbe.htm for details for this

sort of
thing.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Rohit Thomas" wrote in message
...
Hello All,

Is it possible to delete a userform or module from an
Excel project programmatically? If it is possible, can

you
provide some sample code or point me to a website where

I
can find some?

Thanks,
Rohit Thomas



.


Randall Arnold[_2_]

Delete userform/module using VB
 
Rohit, you can use the following:

ThisWorkbook.Unprotect Password:="passwd"

Substitute your known password for "passwd".

Protect works the same way. Same goes for the ActiveWorksheet. Execute
them in the Workbook_Open and Workbook_BeforeClose event subs.

Randall Arnold

"Rohit Thomas" wrote in message
...
Chip,

Thanks for the response. I took a look at your website and
have one question....If my project is password protected,
is there code that I can run to unprotect it before
deleting the userform or module. It would need to be
protected after the useform or module is deleted.

Thanks,
Rohit
-----Original Message-----
Rohit,

See www.cpearson.com/excel/vbe.htm for details for this

sort of
thing.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Rohit Thomas" wrote in message
...
Hello All,

Is it possible to delete a userform or module from an
Excel project programmatically? If it is possible, can

you
provide some sample code or point me to a website where

I
can find some?

Thanks,
Rohit Thomas



.




Chip Pearson

Delete userform/module using VB
 
Randall,

ThisWorkbook.Unprotect Password:="passwd"



That doesn't unprotect the VBProject -- the VBA code behind the
workbook. Unfortunately, there is no way to programmatically
protect or unprotect a VBProject. You can sometimes get SendKeys
to do it, but I don't recommend it.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Randall Arnold" wrote in message
...
Rohit, you can use the following:

ThisWorkbook.Unprotect Password:="passwd"

Substitute your known password for "passwd".

Protect works the same way. Same goes for the ActiveWorksheet.

Execute
them in the Workbook_Open and Workbook_BeforeClose event subs.

Randall Arnold

"Rohit Thomas" wrote in message
...
Chip,

Thanks for the response. I took a look at your website and
have one question....If my project is password protected,
is there code that I can run to unprotect it before
deleting the userform or module. It would need to be
protected after the useform or module is deleted.

Thanks,
Rohit
-----Original Message-----
Rohit,

See
www.cpearson.com/excel/vbe.htm for details for this
sort of
thing.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Rohit Thomas" wrote in message
...
Hello All,

Is it possible to delete a userform or module from an
Excel project programmatically? If it is possible, can

you
provide some sample code or point me to a website where

I
can find some?

Thanks,
Rohit Thomas


.






Randall Arnold[_2_]

Delete userform/module using VB
 
Ok, you're right-- I was just thinking of the Workbook.

Personally, I don't think it's a good thing to be able to programmatically
unprotect the code... one has to simultaneously deal with self-reference,
quantum mechanics and time travel. Who needs THAT???

; )

Randall Arnold

"Chip Pearson" wrote in message
...
Randall,

ThisWorkbook.Unprotect Password:="passwd"



That doesn't unprotect the VBProject -- the VBA code behind the
workbook. Unfortunately, there is no way to programmatically
protect or unprotect a VBProject. You can sometimes get SendKeys
to do it, but I don't recommend it.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Randall Arnold" wrote in message
...
Rohit, you can use the following:

ThisWorkbook.Unprotect Password:="passwd"

Substitute your known password for "passwd".

Protect works the same way. Same goes for the ActiveWorksheet.

Execute
them in the Workbook_Open and Workbook_BeforeClose event subs.

Randall Arnold

"Rohit Thomas" wrote in message
...
Chip,

Thanks for the response. I took a look at your website and
have one question....If my project is password protected,
is there code that I can run to unprotect it before
deleting the userform or module. It would need to be
protected after the useform or module is deleted.

Thanks,
Rohit
-----Original Message-----
Rohit,

See
www.cpearson.com/excel/vbe.htm for details for this
sort of
thing.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Rohit Thomas" wrote in message
...
Hello All,

Is it possible to delete a userform or module from an
Excel project programmatically? If it is possible, can
you
provide some sample code or point me to a website where
I
can find some?

Thanks,
Rohit Thomas


.









All times are GMT +1. The time now is 10:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com