?
Solved

PDF open in Full Screen mode from Access

Posted on 2012-08-10
10
Medium Priority
?
755 Views
Last Modified: 2012-08-14
Hi Experts,

I have a report printing to a PDF file, but I want it to open in full screen mode to be displayed on an overhead monitor. I could easily just push Ctrl+L, but I may not always be the one running this database. I have vbMaximizedFocus in my code already, but it displays the same as vbNormalFocus. Any ideas?

Thanks.
0
Comment
Question by:felder25
  • 5
  • 3
  • 2
10 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38282240
Post your code please...
0
 

Author Comment

by:felder25
ID: 38282257
Private Sub Command2_Click()
On Error GoTo Err_Command0_Click

Dim strAttach As String
strAttach = "\\Tdmsgc01\Groups\CQES\Nick\2012 Olympics\ROverallReport.pdf"

If IsFileOpen(strAttach) = "Open" Then
    MsgBox "The 2012 Marketing/Finance Overall Report is already open." & vbCrLf & _
    "Please close the PDF file before running the report.", vbCritical
Exit Sub

Else

DoCmd.SetWarnings False
DoCmd.OpenQuery "QRankTable"
DoCmd.OutputTo acOutputReport, "ROverallReport", acFormatPDF, strAttach
ShellExecute 0, vbNullString, strAttach, vbNullString, vbNullString, vbMaximizedFocus
DoCmd.SetWarnings True

End If


Err_Command0_Click:
End Sub
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 600 total points
ID: 38284300
You could try the SendKeys statement to send the CTRL+L.  You just need to add a wait time for the program to open up before sending the keys.  
Add this declaration to the top of a module:
Public Declare Function Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) As Long

Here's the code with the SendKeys:
    Dim strAttach As String, strPDF As String
    strPDF = "ROverallReport.pdf"
    strAttach = "\\Tdmsgc01\Groups\CQES\Nick\2012 Olympics\" & strPDF
    
    
    If IsFileOpen(strAttach) = "Open" Then
        MsgBox "The 2012 Marketing/Finance Overall Report is already open." & vbCrLf & _
        "Please close the PDF file before running the report.", vbCritical
    Else
        CurrentDb.Execute "QRankTable", dbFailOnError
        DoCmd.OutputTo acOutputReport, "ROverallReport", acFormatPDF, strAttach
        ShellExecute 0, vbNullString, strAttach, vbNullString, vbNullString, vbMaximizedFocus
        Sleep 2000          'wait for pdf to open
        AppActivate strPDF  'set focus to pdf
        SendKeys "^l", True    'this is a lower case L
    End If

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38284472
And to be sure, ...
The OutputTo command includes a last argument that will open the file automatically after you create it.

So try this as well:
DoCmd.OutputTo acOutputReport, "ROverallReport", acFormatPDF, strAttach, True
0
 

Author Closing Comment

by:felder25
ID: 38287665
This worked perfectly. Thanks!
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38287715
just curious...

What happened when you added the TRUE argument to the OutputTo command?
0
 

Author Comment

by:felder25
ID: 38287802
I got the same result with or without TRUE.
0
 

Author Comment

by:felder25
ID: 38287853
When I try and run a second report after having one open, I get the following error:

"Run-time error '5': Invalid procedure call or argument."

Any suggestions??
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38290243
At what line is the error occurring?  Where you able to open a second report before this change with the SendKeys?
0
 

Author Comment

by:felder25
ID: 38291994
It opens, but it doesn't maximize and gives the error. I think you can only have one PDF maximized at a time. I just put in code to check if any of the reports are open to alert the user to close the current PDF before opening a second report.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we develop an application in Ms Access 2016 we should also try to protect the queries, macros and table links. I know I may not have a permanent solution but for novice users, they will not manage to break your application. Below is the detail …
A quick solution showing how to control and open a POS Cash Register Drawer using VBA with MS Access.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question