Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default need help understanding syntax for adding a page to multipage

this is the syntax the help page says to add a page to a multipage

Set Object = object.Add( [ Name [, Caption [, index]]])

so I created a commandbutton, outside of the multipage control an
coded as;

private sub commandbutton1_click()
set multipage1 = page.add( [page3 [, Page3 [, 2]]])
end sub

but I am receiving an error

"invalid use of property" and Multipage1 is highlighted.

I have checked the name and it is correct.


any help

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default need help understanding syntax for adding a page to multipage

Greg,

This works for me

Private Sub CommandButton1_Click()
Dim myObj As Object

Set myObj = MultiPage1.Pages.Add("Page3")
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"GregJG " wrote in message
...
this is the syntax the help page says to add a page to a multipage

Set Object = object.Add( [ Name [, Caption [, index]]])

so I created a commandbutton, outside of the multipage control and
coded as;

private sub commandbutton1_click()
set multipage1 = page.add( [page3 [, Page3 [, 2]]])
end sub

but I am receiving an error

"invalid use of property" and Multipage1 is highlighted.

I have checked the name and it is correct.


any help?


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default need help understanding syntax for adding a page to multipage

Thanks Bob!!

I have spent the last 3 hours trying to figure this out.

ms help is pretty vagu

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default need help understanding syntax for adding a page to multipage

This is a new project for me, have never messed with multipage before.

i am going to be adding a commandbutton that will add a sheet for ever
trip that is made to a job location.

ie; trip1, trip2 ect..

so, in theory I want to do an If_Then statement

Private Sub CommandButton1_Click()
Dim myObj As Object
if Multipage1.Pages("trip1") = true then
Set myObj = MultiPage1.Pages.Add("Trip2")
end if
End Sub


do ya think something like that will work

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default need help understanding syntax for adding a page to multipage

The problem that I find with help is that you drill down into a method for
the object you are interested in, and then find it has concatenated many
topics, and gives an example that isn't applicable to your situation.

C'est la vie.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"GregJG " wrote in message
...
Thanks Bob!!

I have spent the last 3 hours trying to figure this out.

ms help is pretty vague


---
Message posted from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default need help understanding syntax for adding a page to multipage

Greg,

You will need to test in a loop for all of them using that approach, but
it's easier than that

Private Sub CommandButton1_Click()
Dim myObj As Object

With MultiPage1
Set myObj = .Pages.Add("Trip" & .Pages.Count + 1)
End With
End Sub

But you have a basic design flaw here. Whilst the form is up, and you add
new pages, all will work okay. However, these controls are added at runtime,
and will disappear when you close the form down, and will not exist the next
time you open the form, you will just have the design pages.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"GregJG " wrote in message
...
This is a new project for me, have never messed with multipage before.

i am going to be adding a commandbutton that will add a sheet for every
trip that is made to a job location.

ie; trip1, trip2 ect..

so, in theory I want to do an If_Then statement

Private Sub CommandButton1_Click()
Dim myObj As Object
if Multipage1.Pages("trip1") = true then
Set myObj = MultiPage1.Pages.Add("Trip2")
end if
End Sub


do ya think something like that will work?


---
Message posted from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default need help understanding syntax for adding a page to multipage

it will still disappear even though I use a savebutton

thisworkbook.saveas.filename: =

and having

Private Sub Workbook_Open()
userform1.show
End Sub

that when I reopen the workbook, all of the tabs wouldn't show?

perhaps doing something like

Private Sub Workbook_open()
userform1.show
call commandbuttons
end sub

?

--
Message posted from http://www.ExcelForum.com

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default need help understanding syntax for adding a page to multipage

right now, i am working on a printpreview problem, but as soon as
finish this, I will be ready for the multipage project.

I really appreciate your posts!

--
Message posted from http://www.ExcelForum.com

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default need help understanding syntax for adding a page to multipage

Greg,

Yes it will disappear because you are only adding the controls to the form
in memory, not the form in the workbook.

The only way around it that I can see is to save the in formation on a
worksheet when the form terminates, and then when you show it, check that
worksheet and re-create it. Something like this, but firts delete the
multipage from your userform, as it also gets created dynamically with this
approach

Private Sub UserForm_Terminate()
Dim i As Long
Dim pge
Dim oPages As MultiPage

On Error GoTo ut_exit
Set oPages = Me.Controls("TripsPages")
With Worksheets("Trips")
For i = 0 To oPages.Count - 1
Cells(i + 1, "A").Value = oPages(i).Caption
Next i
End With

ut_exit:
End Sub

When you open the form, use code like this

Private Sub UserForm_Initialize()
Dim oPages As MultiPage
Dim oPage As Page
Dim oSaved As Worksheet
Dim i As Long
Dim cRows As Long

Set oPages = Me.Controls.Add("Forms.Multipage.1")
With oPages
For Each oPage In .Pages
.Pages.Remove oPage.Caption
Next oPage
.Name = "TripsPages"
.Left = 20
.Top = 20
Set oSaved = Worksheets("Trips")
cRows = oSaved.Cells(Rows.Count, "A").End(xlUp).Row
If cRows = 1 And oSaved.Range("A1") = "" Then
Exit Sub
End If
For i = 1 To cRows
Set oPage = .Add("Trip" & i)
Next
End With

End Sub

and finally, you need to amend the commandbutton code to

Private Sub CommandButton1_Click()
Dim opage As Page

With Me.Controls("TripsPages")
Set opage = .Pages.Add("Trip" & .Pages.Count + 1)
End With
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"GregJG " wrote in message
...
it will still disappear even though I use a savebutton

thisworkbook.saveas.filename: =

and having

Private Sub Workbook_Open()
userform1.show
End Sub

that when I reopen the workbook, all of the tabs wouldn't show?

perhaps doing something like

Private Sub Workbook_open()
userform1.show
call commandbuttons
end sub

??


---
Message posted from http://www.ExcelForum.com/



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default need help understanding syntax for adding a page to multipage

Hey Bob, I'm back and ready to start on this multipage thing.

this is what I was hoping to do.

create a workbook1 that, when opened, automatically opens userform1 s
the user only sees the form (this I have done in the past). When th
user inputs information on the form and hits the save button, a ne
workbook2.sheet1 is created with each box value from the userfor
placed in certain cells.

i.e.: the first page on the form has 102 checkboxes, textboxes an
comboboxes. when the command button to save is clicked a new workboo
is created and each box value is placed in column A lines 1 thru 102
and the workbook is saved with a specific name.

on my userform1, create a combobox, listbox or perhaps a filedialo
box (I have never tried creating a file dialog box in vba).
that show a list of the workbook2's and when the file is clicked, i
opens the workbook2, fills in the 102 boxes on the userform1 with th
info in the 102 cells , then the workbook2 is closed.

the reason i want to try this is to save HD space. the userform file i
1mb, where as the info needed for the form is only 4kb. that way i a
only adding 4kb to my harddrive instead of the 1mb.

make sense? do ya think there is an easier way? I would be intereste
in hearing any opinion ya have.

Thanks for your time

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
activate a page of a Multipage in Userform Jeff Excel Discussion (Misc queries) 1 February 8th 08 06:16 PM
hide a page on a multipage control Spencer Hutton[_2_] Excel Programming 1 April 22nd 04 02:07 PM
how to put a reference from a page of a multipage form to another page Valeria[_2_] Excel Programming 2 January 25th 04 08:21 AM
Enable/disable page on multipage Phillip Topping Excel Programming 3 November 24th 03 02:07 AM
Adding components to multipage programatically Nigel Brown[_2_] Excel Programming 0 August 4th 03 10:25 AM


All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"