View Single Post
 
Old 10-25-2020, 11:11 AM
Pastor Pastor is offline Windows 10 Office 2019
Novice
 
Join Date: Oct 2020
Posts: 4
Pastor is on a distinguished road
Default

John,

Here is the code that works in EXEC that I mentioned in my previous response that has worked for years. With my best attempts to modify the code as little as possible to get it to work in the ppt code module file It failed at the renaming of the newly created user form.

'************************************************* **********
'* PUT THIS CODE IN THE REBUILD MODULE... *
'* *
'************************************************* **********
'************************************************* ***
'* Rebuild the form *
'************************************************* ***
'* p_Rebuild_Form _
'* sFormName:=c_sFormName, _
'* sCaption:=c_sCaption, _
'* bShowModal:=False, _
'* bEnabled:=True, _
'* lBackColor:=vbBlue, _
'* lForeColor:=vbYellow, _
'* sTag:=c_sTag, _
'* iZoom:=100, _
'* iTop:=iTop, _
'* iLeft:=iLeft, _
'* iHeight:=iHeight, _
'* iWidth:=iWidth

'************************************************* **********
'* P_REBUILD_FORM *
'************************************************* **********
Public Sub p_Rebuild_Form( _
ByVal sFormName As String, _
ByVal sCaption As String, _
ByVal bShowModal As Boolean, _
ByVal bEnabled As Boolean, _
ByVal lBackColor As Long, _
ByVal lForeColor As Long, _
ByVal sTag As String, _
ByVal iZoom As Integer, _
ByVal iTop As Integer, _
ByVal iLeft As Integer, _
ByVal iHeight As Integer, _
ByVal iWidth As Integer)

'OBJECTS DECLARATIONS
Dim oForm As Object

'Create a FORM = .Add(3) /3 = FORM's type value
Set oForm = ThisWorkbook.VBProject.VBComponents.Add(3)

'Update the FORM Properties
With oForm

'FORM: IDENTIFICATION PROPERTIES
.Properties("Name") = sFormName
.Properties("Caption") = sCaption

'FORM: BEHAVIOR PROPERTIES
'Use SHOWMODAL = TRUE for form that must have
'all of the focus and when the user must be
'restristed in which form can be selected.
'Use SHOWMODAL = FALSE for when multiple forms
'are on display and the user can select any for
'that the user wants.
.Properties("ShowModal") = bShowModal
.Properties("Enabled") = bEnabled

'FORM: APPEARANCE PROPERTIES
.Properties("BackColor") = lBackColor
.Properties("ForeColor") = lForeColor

'FORM: MISCELLANEOUS PROPERTIES
.Properties("Tag") = sTag
.Properties("Zoom") = iZoom

'FORM: POSITION PROPERTIES
.Properties("StartUpPosition") = 0
.Properties("Top") = iTop
.Properties("Left") = iLeft
.Properties("Height") = iHeight
.Properties("Width") = iWidth

End With

'Let the operating system catch up
VBA.DoEvents

End Sub

Thanks.
Reply With Quote