I keep getting this message when I try and print a PDF from within my program. This is a one line of code that calls the fhandleFile that I picked up from Dev Ashish. It was working when I tested it but that was quite some time ago. I was doing some changes and happened to click on the button to run this the PDF shows up just fine but then I get that error. This is the code to run the print - Print fHandleFile(App_path + "\manual.pdf", WIN_NORMAL)
-
The fHandlefile code is - '************ Code Start **********
-
' This code was originally written by Dev Ashish.
-
' It is not to be altered or distributed,
-
' except as part of an application.
-
' You are free to use it in any application,
-
' provided the copyright notice is left unchanged.
-
'
-
' Code Courtesy of
-
' Dev Ashish
-
'
-
Private Declare Function apiShellExecute Lib "shell32.dll" _
-
Alias "ShellExecuteA" _
-
(ByVal hWnd As Long, _
-
ByVal lpOperation As String, _
-
ByVal lpFile As String, _
-
ByVal lpParameters As String, _
-
ByVal lpDirectory As String, _
-
ByVal nShowCmd As Long) _
-
As Long
-
-
'***App Window Constants***
-
Private Const WIN_NORMAL = 1 'Open Normal
-
Private Const WIN_MAX = 3 'Open Maximized
-
Private Const WIN_MIN = 2 'Open Minimized
-
-
'***Error Codes***
-
Private Const ERROR_SUCCESS = 32&
-
Private Const ERROR_NO_ASSOC = 31&
-
Private Const ERROR_OUT_OF_MEM = 0&
-
Private Const ERROR_FILE_NOT_FOUND = 2&
-
Private Const ERROR_PATH_NOT_FOUND = 3&
-
Private Const ERROR_BAD_FORMAT = 11&
-
'***************Usage Examples***********************
-
'Open a folder: ?fHandleFile("C:\TEMP\",WIN_NORMAL)
-
'Call Email app: ?fHandleFile("mailto:dash10@hotmail.com",WIN_NORMAL)
-
'Open URL: ?fHandleFile("http://home.att.net/~dashish", WIN_NORMAL)
-
'Handle Unknown extensions (call Open With Dialog):
-
' ?fHandleFile("C:\TEMP\TestThis",Win_Normal)
-
'Start Access instance:
-
' ?fHandleFile("I:\mdbs\CodeNStuff.mdb", Win_NORMAL)
-
'****************************************************
-
-
Function fHandleFile(stFile As String, lShowHow As Long)
-
Dim lRet As Long, varTaskID As Variant
-
Dim stRet As String
-
Dim Vresponse As String
-
'First try ShellExecute
-
lRet = apiShellExecute(hWndAccessApp, vbNullString, _
-
stFile, vbNullString, vbNullString, lShowHow)
-
-
If lRet > ERROR_SUCCESS Then
-
stRet = vbNullString
-
lRet = -1
-
Else
-
Select Case lRet
-
Case ERROR_SUCCESS:
-
varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
-
& stFile, WIN_NORMAL)
-
lRet = (varTaskID <> 0)
-
Case ERROR_NO_ASSOC:
-
'Try the OpenWith dialog
-
varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
-
& stFile, WIN_NORMAL)
-
lRet = (varTaskID <> 0)
-
Case ERROR_OUT_OF_MEM:
-
stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
-
Case ERROR_FILE_NOT_FOUND:
-
stRet = "Error: Adobe acrobat reader not installed. Couldn't Execute!"
-
Case ERROR_PATH_NOT_FOUND:
-
stRet = "Error: Path not found. Couldn't Execute!"
-
Case ERROR_BAD_FORMAT:
-
stRet = "Error: Bad File Format. Couldn't Execute!"
-
Case Else:
-
End Select
-
End If
-
fHandleFile = lRet & IIf(stRet = "", vbNullString, ", " & stRet)
-
If fHandleFile = -1 Then
-
-
Else
-
Vresponse = MsgBox(fHandleFile, vbOKOnly, "" & VMsgtitle & "")
-
End If
-
End Function
-
The FHandlefile runs fine and the PDF prints the error is on the Print line.
I don't know if I'm missing a reference or what.
Any help .
Tom,
Have you tried using this:
Assuming you have some pdf reader installed, then you can print with the following command: - CreateObject("Shell.Application").Namespace(0).ParseName("C:\mypdf1.pdf").InvokeVerb ("Print")
You can use the above to print just about any file that supports a right click on the file name and then choosing print.
2 2198 twinnyfo 3,653
Recognized Expert Moderator Specialist
Tom,
Have you tried using this:
Assuming you have some pdf reader installed, then you can print with the following command: - CreateObject("Shell.Application").Namespace(0).ParseName("C:\mypdf1.pdf").InvokeVerb ("Print")
You can use the above to print just about any file that supports a right click on the file name and then choosing print.
I have been using the same code for years but modified it slightly to print. - Public Function fHandleFile(stFile As String, lShowHow As Long, Optional doprint As Boolean = False)
-
Dim lRet As Long, varTaskID As Variant
-
Dim stRet As String, stoperation As String
-
stoperation = vbNullString
-
If doprint Then stoperation = "print"
-
'First try ShellExecute
-
lRet = apiShellExecute(hWndAccessApp, stoperation, _
-
stFile, vbNullString, vbNullString, lShowHow)
-
-
If lRet > ERROR_SUCCESS Then
-
stRet = vbNullString
-
lRet = -1
-
Else
-
Select Case lRet
-
Case ERROR_NO_ASSOC:
-
'Try the OpenWith dialog
-
varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & stFile, WIN_NORMAL)
-
lRet = (varTaskID <> 0)
-
Case ERROR_OUT_OF_MEM:
-
stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
-
Case ERROR_FILE_NOT_FOUND:
-
stRet = "Error: File not found. Couldn't Execute!"
-
Case ERROR_PATH_NOT_FOUND:
-
stRet = "Error: Path not found. Couldn't Execute!"
-
Case ERROR_BAD_FORMAT:
-
stRet = "Error: Bad File Format. Couldn't Execute!"
-
Case Else:
-
End Select
-
End If
-
fHandleFile = lRet & IIf(stRet = "", vbNullString, ", " & stRet)
-
End Function
Sign in to post your reply or Sign up for a free account.
Similar topics
by: |
last post by:
This is a semi-advanced question about ASP VBScript 5.0 classes. If you're
knowledegable, please lend a hand!
VBScript class instances can have properties that have objects assigned to
them....
|
by: Dave Y |
last post by:
I am a newbie to C# and am having trouble trying to override a ListView
property method. I have created a new class derived from the Forms.Listview
and I cannot figure out the syntax to override...
|
by: Don |
last post by:
Is it possible to determine if an object has a certain method or property
available? For example, say I have a function with one parameter of type
Object. At the end of the function I want to...
|
by: Mirek Endys |
last post by:
Hello all,
another problem im solving right now. I badly need to get typeof object that
called static method in base classe. I did it by parameter in method Load,
but i thing there should be...
|
by: Bremanand |
last post by:
Hi...
i need the solution of Why C# doesnt support Multiple inheritance????
Let me know the solution plz..
Thanks&Regards,
Bremanand.S
|
by: Charles |
last post by:
I have a validation script used before submitting a form. When
executed it says "Object doesn't support property or method". I'm
using onclick="return validate();" which should be fine. But when...
|
by: callre |
last post by:
when i used javascript onchange() the error is coming "object doesnt support this property" my code is-
<script type='text/javascript' language="javascript">
function change()
{ ...
|
by: acoder |
last post by:
Problem
When setting the FORM object's action property an "Object does not support this property or method" error occurs
Browser
Internet Explorer 6-
Example
The Javascript code:
var...
|
by: Zahir Malik |
last post by:
Hi Guys
I am having an wearied issue and need your expert opinions on this. I am not network geek so may be that is why in trouble.
Here is the issue:
We have an web application running on...
|
by: shaker |
last post by:
I am getting the following Java Script error: when i opened my project in IE9. "Microsoft JScript runtime error: Object doesn't support property or method '__defineGetter__'" how can i solve this...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |