I am trying to create a form using vba code. For that I am using the following code:
PrivateSub createButton_Click()'Locks Excel spreadsheet and speeds up form processing
Application.VBE.MainWindow.Visible =False
choNum = choiceNumSet TempForm = ActivePresentation.VBProject.VBComponents.Add(vbext_ct_MSForm)With TempForm.Properties("Caption")="Possible answers".Properties("Width")=300.Properties("Height")=10+34* choiceNum +50EndWith
FormName = TempForm.NameFor i =1To choiceNumSet newTab = TempForm.Designer.Controls.Add("Forms.Label.1","label"& i,True)With newTab.Caption ="Answer"& i.width =40.height =15.top =10+30*(i -1).left =10EndWithSet cCntrl = TempForm.Designer.Controls.Add("Forms.TextBox.1","textBox"& i,True)With cCntrl.width =150.height =15.top =10+30*(i -1).left =60.ZOrder (0)EndWithNext iSet NewButton = TempForm.Designer.Controls.Add("forms.CommandButton.1","answerButton",True)With NewButton.Caption ="Create survey".left =60.top =30* choiceNum +10EndWith
ActiveWindow.Selection.UnselectSet cSlide = Application.ActiveWindow.View.SlideSet survey = cSlide.Shapes.AddTextbox(msoTextOrientationHorizontal,20,20,400,20)
survey.TextFrame.TextRange.Font.Size =25
survey.TextFrame.TextRange.text = tagBox
height = survey.height
survey.Select
tagBox.text =""
choiceNum =""
surveyCreation.Hide
VBA.UserForms.Add(FormName).Show
ActivePresentation.VBProject.UserFormsEndSub
But it is giving me an error in the row VBa.UserFomrs.Add(FormName).Show I created this macro in one presentation but I am using it in another presentation. If I use it in the presentation that I created it works. What can I do to make it work also in another presentation?