#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Multipage??

In my userform, below is the code to exit out of the userform. However, my
userform consists of a Multipage1 with over 10 pages. As individual goes
through the pages they end at the last page and can print etc. However,
after printing the code takes individual back to the last page where they
left off. How do I code so that it takes the user back to page1 of the
multipage. I tried all sorts, but I am not being very successful. I am
wondering if it is at all possible? Thank you in advance for any help you
can provide.



Private Sub CommandButton3_Click()

If MsgBox("Do you want to Exit?", vbOKCancel, "Exit or Cancel??") = vbOK Then
'whatever you want to do
ActiveWorkbook.Close 'closes the workbook
Unload Me 'closes the form


End If

End Sub



Private Sub CommandButton6_Click()
MsgBox "Form will scroll through form pages to give you print screens of
form. Please be patient."

Dim myPict As Picture
Dim PrintWks As Worksheet
Dim iCtr As Long
Dim CurPage As Long
Dim DestCell As Range

'set up that sheet one time
Set PrintWks = Workbooks.Add(1).Worksheets(1)

With PrintWks
With PrintWks.PageSetup
.Orientation = xlPortrait
.PrintTitleRows = ""
.PrintTitleColumns = ""

.PrintArea = ""

.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
'.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 90
.PrintErrors = xlPrintErrorsDisplayed
End With

'keep track of what page was active
CurPage = Me.MultiPage1.Value

'loop
For iCtr = 0 To Me.MultiPage1.Pages.Count - 1
Me.MultiPage1.Value = iCtr
Me.Repaint '<-- Added


'do the printing for each page
keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY + _
KEYEVENTF_KEYUP, 0
keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY + _
KEYEVENTF_KEYUP, 0
DoEvents


With PrintWks
Application.Wait Now + TimeValue("00:00:01")
.PasteSpecial Format:="Bitmap", Link:=False, _
DisplayAsIcon:=True

'the last one added
Set myPict = .Pictures(.Pictures.Count)
Set DestCell = .Range("a1").Offset(iCtr, 0)
End With

DestCell.RowHeight = 285
DestCell.ColumnWidth = 105

With DestCell
myPict.Top = .Top
myPict.Height = .Height
myPict.Left = .Left
myPict.Width = .Width

End With

On Error Resume Next
Next iCtr
End With

Me.Hide 'hide the userform
PrintWks.PrintOut preview:=True
If MsgBox("Do you want to Save Print Screens?", vbYesNo, "Yes or No??")
= vbYes Then
PrintWks.Parent.Close savechanges:=True
PrintWks.Parent.Sheet1.Unload
UserForm2.Show

End If

If vbNo Then
ActiveWorkbook.Close 'closes the workbook

UserForm2.Show 'go back to form to exit
End If

Exit Sub

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Multipage??



'Load UserForm2 'Not required if already loaded

UserForm2.MultiPage1.Value = 0

UserForm2.Show

'Notes: 0 = page 1, 1 = page 2 etc.

--
Regards,

OssieMac


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
MultiPage tab JWM6[_5_] Excel Programming 4 April 22nd 06 02:06 AM
MultiPage Bill[_30_] Excel Programming 1 January 13th 06 08:22 PM
vba - using multipage ajliaks[_23_] Excel Programming 3 August 9th 04 01:29 PM
Multipage Aksel Børve Excel Programming 0 March 1st 04 08:24 AM
MultiPage Michael[_25_] Excel Programming 3 January 6th 04 12:49 PM


All times are GMT +1. The time now is 03:59 PM.

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"