Macros with Print Preview

  • Thread starter Thread starter Cheryl
  • Start date Start date
C

Cheryl

Will a macro close print preview. I had a macro perform other tasks, and then
open in print preview, however it will not close the preview.
 
Cheryl,

Yes, a macro can be used to close a print preview. Can you tell us the
details (i.e. actions and arguments) of the macro you are using, and
what Event you are running it on?
 
Steve,
I am changing formats of dates and times, averaging a column, putting a
formula in another column, bolding and setting it up in print preview, but I
can't get it to close.
 
Cheryl,

I understand that it isn't closing.

But what is the macro? And where are you using the macro?
 
The close macro function doesn't work? Open the macro and select save as
module/code. Copy the code and paste in your next post so we can see what
it looks like.
 
Here's the code:
Sub ConvertData()
'
' ConvertData Macro
' Converts date, time, temperature to Celcius, bolds, averages celcius temp,
print preview
'
' Keyboard Shortcut: Ctrl+d
'
Columns("A:A").Select
Selection.NumberFormat = "m/d/yyyy"
Columns("B:B").Select
Selection.NumberFormat = "h:mm;@"
Columns("C:C").EntireColumn.AutoFit
Range("D1").Select
ActiveCell.FormulaR1C1 = "Celcius"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("D2").Select
ActiveCell.FormulaR1C1 = "=5/9*(RC[-1]-32)"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D26"), Type:=xlFillDefault
Range("D2:D26").Select
Columns("D:D").Select
Selection.NumberFormat = "0.0"
Range("A1:D1").Select
Selection.Font.Bold = True
Columns("C:C").ColumnWidth = 11
Range("A27").Select
ActiveCell.FormulaR1C1 = "Average"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("A27").Select
Selection.Font.Bold = True
Range("D27").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-25]C:R[-1]C)"
Range("D27").Select
Selection.Font.Bold = True
Range("F1").Select
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "MediTrax Controls"
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = "Cheryl Sarver"
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.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 = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = False
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
ActiveWindow.SelectedSheets.PrintPreview
End Sub
 
Cheryl,

Amazing how long we took to realise that you are in the wrong room! :-)

You appear to be using Excel. Macros in Excel are VBA procedures , and
are completely different creatures than macros in Access.

The focus of this newsgroup is Macros in Microsoft Access, the database
programme.

You will have a better chance of a good answer to your question if you
re-post it to an Excel related newsgroup.
 
Thank you Steve, I fell asleep, Pete
Steve Schapel said:
Cheryl,

Amazing how long we took to realise that you are in the wrong room! :-)

You appear to be using Excel. Macros in Excel are VBA procedures , and
are completely different creatures than macros in Access.

The focus of this newsgroup is Macros in Microsoft Access, the database
programme.

You will have a better chance of a good answer to your question if you
re-post it to an Excel related newsgroup.
 
Back
Top