Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
MultiPage tab | Excel Programming | |||
MultiPage | Excel Programming | |||
vba - using multipage | Excel Programming | |||
Multipage | Excel Programming | |||
MultiPage | Excel Programming |