prometheus
New Member
- Joined
- Feb 28, 2002
- Messages
- 45
I have an app that I wrote in Excell 2003, now we've upgraded to Excel 2007 and when the print preview command is given there is no "ribbon" menu on the print preview screen. The document appears correct on the screen but cannot be printed. Running it in Exel 2003 does not exhibit this problem.
I am running Windows XP proffesional with SP 3 installed. Excel 2007 has SP2 MSO installed. When the user opens the application I have the folowwing code run to hide the toolbars and lock down the ability to make any changes to the data:
I call the print preview from a command button with the following code:
Even when I try to add the manual print command to the command button's code it does not work properly, it prints a page of jibberish. Any help would be appreciated. I am just a self-taught VBA user. My company's IT dept is trying to help, but only one guy has a decent knowledge of VBA. Thanks.
John
I am running Windows XP proffesional with SP 3 installed. Excel 2007 has SP2 MSO installed. When the user opens the application I have the folowwing code run to hide the toolbars and lock down the ability to make any changes to the data:
Code:
Private Sub Workbook_Open()
Dim optBut As OptionButton
For Each optBut In ActiveSheet.OptionButtons
optBut.Value = False
Next
Application.DisplayFormulaBar = False
ActiveWindow.DisplayHeadings = False
'[G27] = [G27] + 1
'ActiveWorkbook.Save
UserForm1.Show
Application.OnKey "%{F11}", "DisableAltF11"
Application.OnKey "%{F8}", "DisableAltF8"
Call Network
Call VBAProject.Module20.DisableCopyCutAndPaste
Sheet1.TextBox1.Value = "x"
Worksheets("Sheet1").Range("F3").FormulaArray = "=1"
ResetTimer True
Application.DisplayFormulaBar = False
Worksheets("Sheet1").Activate
Worksheets("Sheet1").Range("F10").FormulaArray = "=1"
End Sub
I call the print preview from a command button with the following code:
Code:
Private Sub CommandButton1_Click()
If Range("b2") = "" Then
MsgBox "You must enter a weight"
Range("b2").Select
Else
'Exit Sub
End If
If Range("b3") = "" Then
MsgBox "You must select a drug"
Range("b3").Select
Else
'Exit Sub
End If
If Range("b4") = "" Then
MsgBox "You must enter the amount of drug in the bag"
Range("b4").Select
Else
'Exit Sub
End If
If Range("b10") = "" Then
MsgBox "You must enter the total volume"
Range("b10").Select
Else
'Exit Sub
End If
If Range("l1") = "True" Then
MsgBox "The maximum dosing weight for eptifibatide (Integrilin) is 125 kg. The weight will automatically be changed to 125 kg."
Worksheets("Sheet1").Range("B2").FormulaArray = "=125"
Else
End If
If Range("l2") = "True" Then
MsgBox "The maximum dosing weight for nesiritide (Natrecor) is 175 kg. The weight will automatically be changed to 175 kg."
Worksheets("Sheet1").Range("B2").FormulaArray = "=175"
Else
End If
If Range("n2") = "1" Then
MsgBox "The standard insulin drip contains 100 units per 100ml. Did you want to place a different amount of insulin in this bag?"
Else
End If
If Range("n3") = "1" Then
MsgBox "Note: The heparin protocol order set has a maximum initial infusion rate of 1,500 units per hour, regardless of weight."
Else
End If
If Not (IsEmpty(Range("B2"))) Then
Else
Exit Sub
End If
If Not (IsEmpty(Range("B3"))) Then
Else
Exit Sub
End If
If Not (IsEmpty(Range("B4"))) Then
Else
Exit Sub
End If
If Not (IsEmpty(Range("B10"))) Then
Else
Exit Sub
End If
Sheets("Sheet2").Visible = True
Sheets("Sheet2").Select
Worksheets("Sheet2").Activate
Application.ScreenUpdating = True
Me.PageSetup.printarea _
= Me.Parent.Names(Me.Range("B3").Value).RefersToRange.Address
Worksheets("Sheet2").PageSetup.printarea = (Me.Range("B3").Value)
'The False parameter prevents changes in Preview mode.
ActiveSheet.PrintPreview True
'Prevent user switching to "Page Brake Preview".
'ActiveWindow.View = xlNormalView
ActiveWindow.zoom = 100
'ShowCommandBar = True
'Application.SendKeys ("%z")
Worksheets("Sheet2").Activate
'ActiveWindow.SelectedSheets.PrintPreview
Worksheets("sheet1").Activate
'ActiveDocument.ClosePrintPreview
Worksheets("Sheet1").Activate
Sheets("Sheet2").Visible = False
Range("B1").Select
Selection.ClearContents
Range("B2").Select
Selection.ClearContents
Range("B3").Select
Selection.ClearContents
Range("C2").Select
Selection.ClearContents
Range("C3").Select
Selection.ClearContents
Range("B4").Select
Selection.ClearContents
Range("B10").Select
Selection.ClearContents
Range("E1").Select
Selection.ClearContents
'Application.SendKeys ("%fx")
'Application.SendKeys ("n")
End Sub
Even when I try to add the manual print command to the command button's code it does not work properly, it prints a page of jibberish. Any help would be appreciated. I am just a self-taught VBA user. My company's IT dept is trying to help, but only one guy has a decent knowledge of VBA. Thanks.
John
Last edited by a moderator: