Specific Question in Excel/Forms/Multipage Functionality

Pvaulter13

New Member
Joined
Nov 25, 2013
Messages
10
I'm getting multipage in form to work very nicely, I press a button it adds a page, copies what's on that page and puts it in the new page. I've posted my code below, someone can probably use the Add delete functionality.

However, the problem arrives when you add an additional multipage on the same form. When you add multipage6 after multipage5 is there, Multipage 5 VBA code no longer works. I get an error code "the object invoked disconnect from client" or something similar.

Am I missing any code? What am I doing wrong? I've spend hrs on this, trying different tricks, moving code around, deleting & starting over.

Any help would be greatly appreciated-

Regards





Private Sub CommandButton9_Click()
Dim i As Integer
MultiPage5.Select (0)
MultiPage5.Pages.Add
i = MultiPage5.Count
MultiPage5.Pages(0).Controls.Copy
MultiPage5.Pages(i - 1).Paste
End Sub
Private Sub CommandButton10_Click()
Dim j As Long
j = MultiPage5.Pages.Count


If j = 1 Then
MsgBox ("Cannot delete this page")
Else
MultiPage5.Pages.Remove "Page" & j
End If
End Sub


Private Sub CommandButton11_Click()
Dim h As Integer
MultiPage6.Select (0)
MultiPage6.Pages.Add
h = MultiPage6.Count
MultiPage6.Pages(0).Controls.Copy
MultiPage6.Pages(h - 1).Paste
End Sub
Private Sub CommandButton12_Click()
Dim k As Long
k = MultiPage6.Pages.Count


If k = 1 Then
MsgBox ("Cannot delete this page")
Else
MultiPage5.Pages.Remove "Page" & k
End If
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I've done a little testing and I get the same error. It seems that Excel doesn't like it when there's two multipage controls on the userform and you're trying to add a page. If you're not able to find an acceptable solution, one workaround might be to first add a number of pages and make them invisible. Then you can make a page visible whenever you need one. So, basically, when you click on a commandbutton, it cycles through each page. And when it finds the first page that's not visible, it makes it visible and exits the sub.
 
Upvote 0
I've done a little testing and I get the same error. It seems that Excel doesn't like it when there's two multipage controls on the userform and you're trying to add a page. If you're not able to find an acceptable solution, one workaround might be to first add a number of pages and make them invisible. Then you can make a page visible whenever you need one. So, basically, when you click on a commandbutton, it cycles through each page. And when it finds the first page that's not visible, it makes it visible and exits the sub.


Hi Dom,

That's a réal good idea, I think that might work. Thanks for the answer, greatly appreciated.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,181
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top