Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 将新选项卡页复制并粘贴到MSForms.page中_Excel_Vba_Multipage - Fatal编程技术网

Excel 将新选项卡页复制并粘贴到MSForms.page中

Excel 将新选项卡页复制并粘贴到MSForms.page中,excel,vba,multipage,Excel,Vba,Multipage,我在Excel中有一个带有多页对象的UserForm。我需要通过复制和粘贴一个现有的选项卡页面,将更多的选项卡页面动态地添加到MultiPage对象中。 任何帮助都将不胜感激 谢谢您可以使用这段代码来完成这项工作 Option Explicit Private Sub CommandButton1_Click() '~~> Change 1 to the respective page index which you want to replicate MultiPag

我在Excel中有一个带有多页对象的UserForm。我需要通过复制和粘贴一个现有的选项卡页面,将更多的选项卡页面动态地添加到MultiPage对象中。 任何帮助都将不胜感激


谢谢

您可以使用这段代码来完成这项工作

Option Explicit

Private Sub CommandButton1_Click()

    '~~> Change 1 to the respective page index which you want to replicate
    MultiPage1.Pages(1).Controls.Copy

    '~~> Add a New page
    MultiPage1.Pages.Add

    '~~> Paste the copied controls
    MultiPage1.Pages(MultiPage1.Pages.Count - 1).Paste

End Sub
快照


嗨,西德哈特,谢谢你的回复。我刚刚做了,它在示例代码中运行良好,但当我将其与代码集成时,Excel会在MultiPage1.Pages.Add行重新启动。我想这是因为我在每个现有的选项卡页面中都有很多控件。我尝试使用TabStrip而不是MultiPage。这样,我就可以对所有选项卡页面使用一组控件。