LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default SendKeys Help

In the program that I am working on, I copy and paste filtered data into a
new workbook multiple times. Each time that I complete this procedure, I set
the print preview to be set up a certain way. In order to be able to get out
of the print preview screen, I used SendKeys to click through it. When I run
just the sub for 1 instance of creating the new workbook, copying and pasting
the filtered data, etc., it works fine; but when I run the entire program and
it gets to the print preview screen, the SendKeys statement doesn't work. I
discovered that something causes the active screen to be inactive because if
I manually press Alt and C, nothing happens.

So, my question is, what can cause the screen to become inactive that would
cause SendKeys to not work? and what can I do to rectify this? thanks

This is the individual part that works fine by itself


Sub File1000()
Selection.AutoFilter Field:=2, Criteria1:="1000"
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Columns("A:G").Select
Selection.Columns.AutoFit
Columns("H:V").Select
Selection.ColumnWidth = 10
With ActiveSheet.PageSetup
.PrintTitleRows = "$4:$4"
.PrintTitleColumns = ""
End With
Range("A4").Select
Sheets(Array("Sheet2", "Sheet3")).Select
Sheets("Sheet3").Activate
Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "1000"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "Page &P of &N"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 70
.PrintErrors = xlPrintErrorsDisplayed
End With
Application.SendKeys ("{%}c")
ActiveWindow.SelectedSheets.PrintPreview
Range("E2").Select
End Sub
 
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
SendKeys [email protected] Excel Programming 1 July 25th 05 06:05 PM
SendKeys in VBA John Excel Programming 1 June 24th 05 05:46 PM
SendKeys Mike Excel Programming 2 July 2nd 04 12:47 AM
Sendkeys GB[_3_] Excel Programming 0 September 16th 03 10:39 PM
SendKeys Ron de Bruin Excel Programming 3 August 25th 03 10:21 PM


All times are GMT +1. The time now is 04:22 PM.

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

About Us

"It's about Microsoft Excel"