473,467 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Started getting Object doesn't support this property or method

489 Contributor
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
Expand|Select|Wrap|Line Numbers
  1. Print fHandleFile(App_path + "\manual.pdf", WIN_NORMAL)
  2.  
The fHandlefile code is
Expand|Select|Wrap|Line Numbers
  1. '************ Code Start **********
  2. ' This code was originally written by Dev Ashish.
  3. ' It is not to be altered or distributed,
  4. ' except as part of an application.
  5. ' You are free to use it in any application,
  6. ' provided the copyright notice is left unchanged.
  7. '
  8. ' Code Courtesy of
  9. ' Dev Ashish
  10. '
  11. Private Declare Function apiShellExecute Lib "shell32.dll" _
  12.     Alias "ShellExecuteA" _
  13.     (ByVal hWnd As Long, _
  14.     ByVal lpOperation As String, _
  15.     ByVal lpFile As String, _
  16.     ByVal lpParameters As String, _
  17.     ByVal lpDirectory As String, _
  18.     ByVal nShowCmd As Long) _
  19.     As Long
  20.  
  21. '***App Window Constants***
  22. Private Const WIN_NORMAL = 1         'Open Normal
  23. Private Const WIN_MAX = 3            'Open Maximized
  24. Private Const WIN_MIN = 2            'Open Minimized
  25.  
  26. '***Error Codes***
  27. Private Const ERROR_SUCCESS = 32&
  28. Private Const ERROR_NO_ASSOC = 31&
  29. Private Const ERROR_OUT_OF_MEM = 0&
  30. Private Const ERROR_FILE_NOT_FOUND = 2&
  31. Private Const ERROR_PATH_NOT_FOUND = 3&
  32. Private Const ERROR_BAD_FORMAT = 11&
  33. '***************Usage Examples***********************
  34. 'Open a folder:     ?fHandleFile("C:\TEMP\",WIN_NORMAL)
  35. 'Call Email app:    ?fHandleFile("mailto:dash10@hotmail.com",WIN_NORMAL)
  36. 'Open URL:          ?fHandleFile("http://home.att.net/~dashish", WIN_NORMAL)
  37. 'Handle Unknown extensions (call Open With Dialog):
  38. '                   ?fHandleFile("C:\TEMP\TestThis",Win_Normal)
  39. 'Start Access instance:
  40. '                   ?fHandleFile("I:\mdbs\CodeNStuff.mdb", Win_NORMAL)
  41. '****************************************************
  42.  
  43. Function fHandleFile(stFile As String, lShowHow As Long)
  44. Dim lRet As Long, varTaskID As Variant
  45. Dim stRet As String
  46. Dim Vresponse As String
  47.     'First try ShellExecute
  48.     lRet = apiShellExecute(hWndAccessApp, vbNullString, _
  49.             stFile, vbNullString, vbNullString, lShowHow)
  50.  
  51.     If lRet > ERROR_SUCCESS Then
  52.         stRet = vbNullString
  53.         lRet = -1
  54.     Else
  55.         Select Case lRet
  56.             Case ERROR_SUCCESS:
  57.                 varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
  58.                         & stFile, WIN_NORMAL)
  59.                 lRet = (varTaskID <> 0)
  60.             Case ERROR_NO_ASSOC:
  61.                 'Try the OpenWith dialog
  62.                 varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
  63.                         & stFile, WIN_NORMAL)
  64.                 lRet = (varTaskID <> 0)
  65.             Case ERROR_OUT_OF_MEM:
  66.                 stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
  67.             Case ERROR_FILE_NOT_FOUND:
  68.                 stRet = "Error: Adobe acrobat reader not installed.  Couldn't Execute!"
  69.             Case ERROR_PATH_NOT_FOUND:
  70.                 stRet = "Error: Path not found. Couldn't Execute!"
  71.             Case ERROR_BAD_FORMAT:
  72.                 stRet = "Error:  Bad File Format. Couldn't Execute!"
  73.             Case Else:
  74.         End Select
  75.     End If
  76.     fHandleFile = lRet & IIf(stRet = "", vbNullString, ", " & stRet)
  77.     If fHandleFile = -1 Then
  78.  
  79.     Else
  80.         Vresponse = MsgBox(fHandleFile, vbOKOnly, "" & VMsgtitle & "")
  81.     End If
  82. End Function
  83.  
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 .
Oct 27 '14 #1

✓ answered by twinnyfo

Tom,

Have you tried using this:

Assuming you have some pdf reader installed, then you can print with the following command:

Expand|Select|Wrap|Line Numbers
  1. 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:

Expand|Select|Wrap|Line Numbers
  1. 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.
Oct 27 '14 #2
Hennepin
25 New Member
I have been using the same code for years but modified it slightly to print.

Expand|Select|Wrap|Line Numbers
  1. Public Function fHandleFile(stFile As String, lShowHow As Long, Optional doprint As Boolean = False)
  2. Dim lRet As Long, varTaskID As Variant
  3. Dim stRet As String, stoperation As String
  4.     stoperation = vbNullString
  5.     If doprint Then stoperation = "print"
  6.     'First try ShellExecute
  7.     lRet = apiShellExecute(hWndAccessApp, stoperation, _
  8.             stFile, vbNullString, vbNullString, lShowHow)
  9.  
  10.     If lRet > ERROR_SUCCESS Then
  11.         stRet = vbNullString
  12.         lRet = -1
  13.     Else
  14.         Select Case lRet
  15.             Case ERROR_NO_ASSOC:
  16.                 'Try the OpenWith dialog
  17.                 varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & stFile, WIN_NORMAL)
  18.                 lRet = (varTaskID <> 0)
  19.             Case ERROR_OUT_OF_MEM:
  20.                 stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
  21.             Case ERROR_FILE_NOT_FOUND:
  22.                 stRet = "Error: File not found.  Couldn't Execute!"
  23.             Case ERROR_PATH_NOT_FOUND:
  24.                 stRet = "Error: Path not found. Couldn't Execute!"
  25.             Case ERROR_BAD_FORMAT:
  26.                 stRet = "Error:  Bad File Format. Couldn't Execute!"
  27.             Case Else:
  28.         End Select
  29.     End If
  30.     fHandleFile = lRet & IIf(stRet = "", vbNullString, ", " & stRet)
  31. End Function
Oct 27 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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....
7
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...
1
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...
6
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...
9
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
2
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...
3
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() { ...
0
acoder
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...
4
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...
0
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...
1
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...
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
isladogs
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.