Author Topic: InternetExplorer.application.body  (Read 1634 times)

0 Members and 1 Guest are viewing this topic.

mkweaver

  • Bull Frog
  • Posts: 352
InternetExplorer.application.body
« on: December 24, 2014, 11:45:21 AM »
The following code has worked for years - until I upgraded internet explorer to version 11:
Code - Auto/Visual Lisp: [Select]
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;;  Routine:   HTMLToIE                                                                        ;;;
  3. ;;;  Purpose:   Display text in an internet explorer window                                     ;;;
  4. ;;;  Arguments: HTML - the html text to put in the window                                       ;;;
  5. ;;;             Title - the document title                                                      ;;;
  6. ;;;             Width - the width of the window in pixels                                       ;;;
  7. ;;;             height - the height of the window in pixels                                     ;;;
  8. ;;;  Notes:     The resulting window will not retain focus and typically ends up behind the     ;;;
  9. ;;;             autocad window.  Alt-tab once will bring it to the front.                       ;;;
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11. (defun HTMLToIE (HTML Title width height / objIEA doc body Start)
  12.   (setq objIEA (vlax-create-object "InternetExplorer.Application"))
  13.   (vlax-put-property objIEA "Toolbar" 0)
  14.   (vlax-put-property objIEA "StatusBar" 0)
  15.   (vlax-put-property objIEA "Width" width)
  16.   (vlax-put-property objIEA "Height" height)
  17.   (vlax-put-property objIEA "Left" 0)
  18.   (vlax-put-property objIEA "Top" 0)
  19.   (vlax-put-property objIEA "Visible" :vlax-true)
  20.   (vlax-invoke objIEA "Navigate2" "about:blank")
  21.   (while (/= 4 (vlax-get-property objIEA "ReadyState"))
  22.     (princ ".")
  23.   )
  24.   (setq doc    (vlax-get-property objIEA "Document")
  25.         body   (vlax-get-property doc "Body")
  26.         parent (vlax-get-property doc "parentWindow")
  27.   )
  28.   (vlax-put-property body "scroll" "yes")
  29.   (vlax-put-property body "InnerHTML" HTML)
  30.   (vlax-put-property doc 'Title Title)
  31.   ;;Wait three seconds
  32.   (guipause 2) 
  33.   (gc)
  34.   (princ)
  35. )

It now fails on
Code - Auto/Visual Lisp: [Select]
  1. (vlax-get-property doc "Body")
with the following error message:
Quote
bad argument type: VLA-OBJECT #<variant 9 [object HTMLBodyElement]>

Suggestions appreciated.

Mike

ronjonp

  • Needs a day job
  • Posts: 7533
Re: InternetExplorer.application.body
« Reply #1 on: December 24, 2014, 11:56:17 AM »
This fixed it for me ( using vlax-get vs. vlax-get-property )
Code - Auto/Visual Lisp: [Select]
  1.   (setq doc    (vlax-get objIEA 'Document)
  2.         body   (vlax-get doc 'body)
  3.         parent (vlax-get doc 'ParentWindow)
  4.   )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

mkweaver

  • Bull Frog
  • Posts: 352
Re: InternetExplorer.application.body
« Reply #2 on: December 24, 2014, 12:09:17 PM »
That did it!

Thanks,
Mike

ronjonp

  • Needs a day job
  • Posts: 7533
Re: InternetExplorer.application.body
« Reply #3 on: December 24, 2014, 12:41:18 PM »
That did it!

Thanks,
Mike

Code - Auto/Visual Lisp: [Select]
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;;  Routine:   HTMLToIE                                                                        ;;;
  3. ;;;  Purpose:   Display text in an internet explorer window                                     ;;;
  4. ;;;  Arguments: HTML - the html text to put in the window                                       ;;;
  5. ;;;             Title - the document title                                                      ;;;
  6. ;;;             Width - the width of the window in pixels                                       ;;;
  7. ;;;             height - the height of the window in pixels                                     ;;;
  8. ;;;  Notes:     The resulting window will not retain focus and typically ends up behind the     ;;;
  9. ;;;             autocad window.  Alt-tab once will bring it to the front.                       ;;;
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11. (defun htmltoie (html title width height / _getprop body doc objiea)
  12.   ;; ronjonp added property check
  13.   (defun _getprop (o prop / p)
  14.     (if (or (= (type (setq p (vlax-get-property o prop))) 'vla-object)
  15.             (= (type (setq p (vlax-get o prop))) 'vla-object)
  16.         )
  17.       p
  18.     )
  19.   )
  20.   (if (setq objiea (vlax-create-object "InternetExplorer.Application"))
  21.     (progn (foreach p '("Toolbar" "StatusBar" "Left" "Top") (vlax-put objiea p 0))
  22.            (vlax-put-property objiea "Width" width)
  23.            (vlax-put-property objiea "Height" height)
  24.            (vlax-put-property objiea "Visible" :vlax-true)
  25.            (vlax-invoke objiea "Navigate2" "about:blank")
  26.            (while (/= 4 (vlax-get-property objiea "ReadyState")) (princ "."))
  27.            (if (and (setq doc (_getprop objiea "Document")) (setq body (_getprop doc "Body")))
  28.              (progn (vlax-put-property body "scroll" "yes")
  29.                     (vlax-put-property body "InnerHTML" html)
  30.                     (vlax-put-property doc 'title title)
  31.                     (foreach x (list body doc objiea) (vlax-release-object x))
  32.              )
  33.              (vlax-release-object objiea)
  34.            )
  35.            ;;Wait three seconds
  36.            ;; (guipause 2)
  37.            (gc)
  38.     )
  39.   )
  40.   (princ)
  41. )
  42. ;; (htmltoie "test" "foo" 500 500)
« Last Edit: December 24, 2014, 12:45:56 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC