Author Topic: lisp to read ms word documents  (Read 5207 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
Re: lisp to read ms word documents
« Reply #15 on: March 04, 2013, 02:06:25 PM »
Error: bad list: "this is a test\r"ActiveX Server returned an
error: The object invoked has disconnected from its clients

any clue what this means?

andrew_nao

  • Guest
Re: lisp to read ms word documents
« Reply #16 on: March 05, 2013, 03:40:22 PM »
does anyone know how i can read a header or footer?
i just am not seeing where in the property of the document the header is called out.


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: lisp to read ms word documents
« Reply #17 on: March 06, 2013, 12:35:19 AM »
You might need to "select" something in the document. It seems the header / footer collection is only obtainable through the selection object:
http://msdn.microsoft.com/en-us/library/office/aa172758%28v=office.11%29.aspx
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

andrew_nao

  • Guest
Re: lisp to read ms word documents
« Reply #18 on: March 06, 2013, 08:45:56 AM »
im prety sure ive been thru all the properties and the properties of properties of the document and i didnt see anything remotely close to being a header but i will go thru it again now that ive had some sleep and im fresh to go.

andrew_nao

  • Guest
Re: lisp to read ms word documents
« Reply #19 on: March 06, 2013, 09:08:54 AM »
found it

Command: (vlax-dump-object (vlax-get-property (vlax-get-property
(vlax-get-property(vlax-get-property wa 'ActiveDocument)'sections) 'First)
'Headers))
; HeadersFooters: nil
; Property values:
;   Application (RO) = #<VLA-OBJECT _Application 0000000021ef4af8>
;   Count (RO) = 3
;   Creator (RO) = 1297307460
;   Parent (RO) = #<VLA-OBJECT Section 00000000381311e8>
;   _NewEnum (RO) = #<IUnknown 0000000033591a20>
T

now how to get the text inside the header?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: lisp to read ms word documents
« Reply #20 on: March 06, 2013, 09:41:40 AM »
Use vlax-for or vla-item.

Code: [Select]
;; Gets all the text and appends them to list 'l'
(vlax-for x (setq headers (vlax-get (vlax-get (vlax-get doc 'sections) 'first) 'headers))
  (setq l (cons (vlax-get (vlax-get x 'range) 'text) l))
)
;; Gets the item at index 1 <-- Use this to drill down and find properties and methods in the VLIDE
(vla-item headers 1)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

andrew_nao

  • Guest
Re: lisp to read ms word documents
« Reply #21 on: March 06, 2013, 10:01:09 AM »
Use vlax-for or vla-item.

ahhh i was missing something..

i was using

 (setq wrds (cons (vlax-get (vlax-get word 'range) 'text) wrds))
but was getting
; error: bad argument type: VLA-OBJECT nil

thanks for the heads up