PC Review


Reply
Thread Tools Rate Thread

Automatically cycle thru pages in preview

 
 
=?Utf-8?B?cmJt?=
Guest
Posts: n/a
 
      20th Apr 2007
I want to be able to open a report in Preview Mode and then have it
automatically cycle through the pages of the report. The purpose is to
project the report on a screen and have it display page after page and, when
it reaches the end, start all over. I have been able to get this to work to
some extent using "SendKeys and "Sleep" commands. The Sleep command was done
by putting the following in a general module:

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Basically, I have a button on a form with an OnClick procedure that does the
following:

1. Opens the report in preview.
2. Looks at the [Pages] field on the report to see how many pages there are.
3. Starts a "For . . . Next" loop with i = 1 to the number of pages in the
report.
4. In the loop, I start with a DoEvents command followed by a "Sleep 5000"
command (causes a 5 second hesitation) and then a "SendKeys "{Right}""
command that acts the same way as hitting the right arrow with the report in
preview mode.
5. When the loop ends, I have it return to the beginning and start over.

As primitive as this is, it works - but there are a lot of pitfalls. I
can't find a way to stop the looping. I can hit "Ctrl-Brk" and stop the
code, but then I have to close the Class Module screen and then close the
report. The menu bar does work during the looping so there is nothing for me
to click on to stop the process.

Also, I don't know if this will work in a runtime environment.

I would be very appreciative of any suggestions on how to handle this with
or without SendKeys. Thanks in advance.

The actual event procedure is pasted below.

Private Sub btnDisplayReport_Click()
On Error GoTo ERR_Display

Dim X As Integer
Dim N As Single
Dim strReport As String
Dim i As Integer

strReport = "rptLineChart"

N = 5 ' 5 second dely before going to next page

START_CYCLE:

DoCmd.OpenReport strReport, acViewPreview
DoCmd.RunCommand acCmdFitToWindow ' resize report to fit on the screen

X = Reports!rptLineChart!Z ' [Z] is the "Pages" field on the report
For i = 1 To X
DoEvents
Sleep N * 1000
SendKeys "{right}"
Next i
DoEvents
DoCmd.Close acReport, strReport

GoTo START_CYCLE

EXIT_Display:
Exit Sub

ERR_Display:
DoCmd.Close acReport, strReport
Resume EXIT_Display

 
Reply With Quote
 
 
 
 
Chuck
Guest
Posts: n/a
 
      22nd Apr 2007
On Fri, 20 Apr 2007 11:14:03 -0700, rbm <noemail@please> wrote:

>I want to be able to open a report in Preview Mode and then have it
>automatically cycle through the pages of the report. The purpose is to
>project the report on a screen and have it display page after page and, when
>it reaches the end, start all over. I have been able to get this to work to
>some extent using "SendKeys and "Sleep" commands. The Sleep command was done
>by putting the following in a general module:
>
> Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
>
>Basically, I have a button on a form with an OnClick procedure that does the
>following:
>
>1. Opens the report in preview.
>2. Looks at the [Pages] field on the report to see how many pages there are.
>3. Starts a "For . . . Next" loop with i = 1 to the number of pages in the
>report.
>4. In the loop, I start with a DoEvents command followed by a "Sleep 5000"
>command (causes a 5 second hesitation) and then a "SendKeys "{Right}""
>command that acts the same way as hitting the right arrow with the report in
>preview mode.
>5. When the loop ends, I have it return to the beginning and start over.
>
>As primitive as this is, it works - but there are a lot of pitfalls. I
>can't find a way to stop the looping. I can hit "Ctrl-Brk" and stop the
>code, but then I have to close the Class Module screen and then close the
>report. The menu bar does work during the looping so there is nothing for me
>to click on to stop the process.
>
>Also, I don't know if this will work in a runtime environment.
>
>I would be very appreciative of any suggestions on how to handle this with
>or without SendKeys. Thanks in advance.
>
>The actual event procedure is pasted below.
>
>Private Sub btnDisplayReport_Click()
>On Error GoTo ERR_Display
>
>Dim X As Integer
>Dim N As Single
>Dim strReport As String
>Dim i As Integer
>
>strReport = "rptLineChart"
>
>N = 5 ' 5 second dely before going to next page
>
>START_CYCLE:
>
>DoCmd.OpenReport strReport, acViewPreview
>DoCmd.RunCommand acCmdFitToWindow ' resize report to fit on the screen
>
>X = Reports!rptLineChart!Z ' [Z] is the "Pages" field on the report
>For i = 1 To X
> DoEvents
> Sleep N * 1000
> SendKeys "{right}"
>Next i
> DoEvents
> DoCmd.Close acReport, strReport
>
>GoTo START_CYCLE
>
>EXIT_Display:
> Exit Sub
>
>ERR_Display:
> DoCmd.Close acReport, strReport
> Resume EXIT_Display


Insert some *break out* code before the line: next i.
The *logic* of the *break out* code:
iif keypress = chr( your choice ) then
Exit Sub (Note Exit, not End)

Can stop *show* at any time.

Chuck

 
Reply With Quote
 
=?Utf-8?B?cmJt?=
Guest
Posts: n/a
 
      22nd Apr 2007
Thanks Chuck, that's a great idea. I will give that a try.

"Chuck" wrote:

>
> Insert some *break out* code before the line: next i.
> The *logic* of the *break out* code:
> iif keypress = chr( your choice ) then
> Exit Sub (Note Exit, not End)
>
> Can stop *show* at any time.
>
> Chuck
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cycle through non-hidden pages only Steve Microsoft Excel Misc 6 16th Oct 2008 08:06 PM
Automatically cycle through a list of Parameters KWhamill Microsoft Access VBA Modules 5 10th Jul 2008 10:38 PM
Automatically Cycle Windows Desktop Themes =?Utf-8?B?YXNq?= Windows XP Customization 0 7th Jun 2007 09:15 AM
How do you automatically cycle through pictures in power point? =?Utf-8?B?S3lsZQ==?= Microsoft Powerpoint 1 7th Mar 2007 08:12 PM
2.0 master pages and codebehind cycle Daves Microsoft ASP .NET 1 12th Mar 2005 03:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:09 AM.