Getting unnecessary 2nd Page

J

Jim May

I found the following code by Tom Oglivy on Google and have applied into my
app.
Just ran it for the first time and it is GREAT, except a second page is
being produced with just a reminent (the width of the top-right "X" box
(displayed) down my page 2 ) about 1/8th of an inch wide and 6 inches tall.
How can I eliminate
this residue so that only one page <<Page 1 is Perfect as is >> It's just
that the
last 1/8th inch of my Page 1 is repeating onto Page 2.


'In a General Module enter:
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Public Const VK_SNAPSHOT = 44
Public Const VK_LMENU = 164
Public Const KEYEVENTF_KEYUP = 2
Public Const KEYEVENTF_EXTENDEDKEY = 1

In the userform module:
Private Sub CommandButton1_Click()
' keybd_event VK_SNAPSHOT, 0, 0, 0
DoEvents
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
Workbooks.Add
Application.Wait Now + TimeValue("00:00:01")
ActiveSheet.PasteSpecial Format:="Bitmap", Link:=False,
DisplayAsIcon:=False
ActiveSheet.Range("A1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close False
End Sub

Thanks in advance for any assistance...

Jim May
 
D

Dave Peterson

Maybe...
right after:
ActiveSheet.Range("A1").Select
add this:
With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With

(Untested)
 
J

Jim May

Dave - That was it !! Much appreciated..
another quicky.. has befallen me.. Sometimes (& now is one of those times)
in my Code sheet - my cursor instead of showing the cross-hair symbol - it
becomes a black square the size of a character. I usually look around to see
if I have mistakenlt touched a key, like the scroll-lock, whatever, but no
joy..

Is there someting that this usualy points to that I can fix?

Thanks,

Jim May
 
J

Jim May

Never mind - it is the INSERT key --- grrrr

Dave Peterson said:
Maybe...
right after:
ActiveSheet.Range("A1").Select
add this:
With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With

(Untested)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top