CAD Forum - Database of tips, tricks and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
CZ | EN | DE
Login or
registration
  Visitors: 7641
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

 

HelpCAD discussion

 
CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.

How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedInsert and format text in word with visual lisp

 Post Reply Post Reply
Author
hildevasco_br View Drop Down
Newbie
Newbie


Joined: 04.Mar.2018
Location: Brazil
Using: AutoCad Map 2017
Status: Offline
Points: 2
Direct Link To This Post Topic: Insert and format text in word with visual lisp
    Posted: 04.Mar.2018 at 21:03

Hello

 

 

I'm having trouble inserting a text file into word and trying to apply font formatting to it.

(defun c:TWORD_1 ( )

(setq txtNomModWor "c:\coco\WD_MODELO01.dotx")

(setq TxtNomArqTmp "c:\coco\ARQTEXTOTMP.TXT")

(setq wordapp (vlax-get-or-create-object "Word.Application"))

(if wordapp

(progn

(vla-put-visible wordapp :vlax-true)

(setq worddocs (vlax-get-property wordapp 'Documents))

(if worddocs

(progn

(vlax-invoke-method worddocs 'Add SLT_ModeloMemorial :vlax-false)

(setq worddoc (vlax-get-property wordapp 'Activedocument))

          (if worddoc

(progn

(vlax-put-property wordapp 'ScreenUpdating :vlax-true)

;Insere arquivo texto externo

(setq ObjSelection (vlax-get-property wordapp 'Selection))

(setq ObjRange (vlax-invoke-method ObjSelection 'Goto 3 1 19))

              (vlax-invoke-method ObjSelection 'InsertFile TxtNomArqTmp "" :vlax-false :vlax-false :vlax-false)

(setq ObjRange (vlax-invoke-method ObjSelection 'Previous))

(vlax-put-property (vlax-get-property ObjRange 'ParagraphFormat) 'Alignment 3) ;runing ok


;************************************

;problem not runing

(vlax-put-property (vlax-get-property ObjRange 'Font) 'Name "Arial") ;not runing

(vlax-put-property (vlax-get-property ObjRange 'Font) 'Size 10) ;not runing

;************************************

(vlax-release-object ObjSelection)

(vlax-release-object ObjRange)

)

)

(vlax-release-object worddoc)

)

)

(vlax-release-object worddocs)

)

)

(vlax-release-object wordapp)

)



(defun c:TWORD_2 ( )

(setq txtNomModWor "c:\coco\WD_MODELO01.dotx")

(setq TxtNomArqTmp "c:\coco\ARQTEXTOTMP.TXT")

(setq wordapp (vlax-get-or-create-object "Word.Application"))

(if wordapp

(progn

(vla-put-visible wordapp :vlax-true)

(setq worddocs (vlax-get-property wordapp 'Documents))

(if worddocs

(progn

(vlax-invoke-method worddocs 'Add SLT_ModeloMemorial :vlax-false)

(setq worddoc (vlax-get-property wordapp 'Activedocument))

          (if worddoc

(progn

(vlax-put-property wordapp 'ScreenUpdating :vlax-true)

;Insere arquivo texto externo

(setq ObjSelection (vlax-get-property wordapp 'Selection))

(setq ObjRange (vlax-invoke-method ObjSelection 'Goto 3 1 19))

              (vlax-invoke-method ObjSelection 'InsertFile TxtNomArqTmp "" :vlax-false :vlax-false :vlax-false)



(vlax-invoke-method ObjSelection 'MoveUp 4 5)


(setq NumLinha

(vlax-invoke-method ObjSelection 'MoveDown 5 NumLinha 1) ;NOT

(vlax-put-property (vlax-get-property ObjSelection 'ParagraphFormat) 'Alignment 3)

(vlax-put-property (vlax-get-property ObjSelection 'Font) 'Name "Arial")

(vlax-put-property (vlax-get-property ObjSelection 'Font) 'Size 10)


(setq ObjRange (vlax-invoke-method ObjSelection 'Previous))

(vlax-put-property (vlax-get-property ObjRange 'ParagraphFormat) 'Alignment 3) ;runing ok


;************************************

;problem not runing

(vlax-put-property (vlax-get-property ObjRange 'Font) 'Name "Arial") ;not runing

(vlax-put-property (vlax-get-property ObjRange 'Font) 'Size 10) ;not runing

;************************************

(vlax-release-object ObjSelection)

(vlax-release-object ObjRange)

)

)

(vlax-release-object worddoc)

)

)

(vlax-release-object worddocs)

)

)

(vlax-release-object wordapp)

)


Thanks if anyone can help me

 

 

Thank you

Thanks
Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,547 seconds.