FELIXJM Posted November 24, 2011 Posted November 24, 2011 To optimize my program access to MSWORD without accessing table OLB need to modify a line in the code below: ;(IF (NOT TBLMSWORD) ; (PROGN ; (SETQ TBLMSWORD (STRCAT #DRV "MSWORD.OLB")) ; (vlax-import-type-library ; :tlb-filename TBLMSWORD ; :methods-prefix "MSWORDm-" ; :properties-prefix "MSWORDp-" ; :constants-prefix "MSWORDc-" ; ) ; ) ;;; (setq MSWORDAPP (vlax-get-or-create-object "Word.Application")) (vla-put-visible MSWORDAPP :vlax-true) (setq docs (vla-get-documents MSWORDAPP)) (SETQ doc (vlax-invoke-method docs 'Add)) (setq paragraphs (vlax-get-property doc 'Paragraphs)) (setq pg (vlax-get-property paragraphs 'last)) (setq range (vlax-get-property pg 'range)) (vlax-put-property (vlax-get-property range 'font) 'name "COURIER NEW") (vlax-put-property (vlax-get-property range 'font) 'size 15) ; (setq WDRANGE (vlax-get-property (vlax-get-property (vlax-get-property MSWORDAPP 'ActiveDocument) 'WORDS) 'last)) ;(mswp-put-alignment (mswp-get-ParagraphFormat range) mswc-wdAlignParagraphCenter) [b](vlax-put-property (vlax-get-property range 'Alignment) 'ParagraphFormat 'wdAlignParagraphCenter) ;<< Error in this line[/b] (vlax-invoke-method range 'InsertAfter "TEXTO NEGRITO, ") ;;; OK... Quote
fixo Posted November 25, 2011 Posted November 25, 2011 (edited) Try instead: (vlax-put-property (vlax-get-property range 'Alignment) 'ParagraphFormat 1) or: (vlax-put-property (vlax-get-property range 'Alignment) 'ParagraphFormat (vlax-make-variant 1 3));<--variant of long Possible alignment constants are 0,1,2 To get numeric values of any constants just type in the Word VBA editor in the immediate window Type: ?wdAlignParagraphCenter and press Enter Same for other stuffs, just don't you forget to type question sign at front of constant But I'm not sure abot that the word is have an alignment property Perhaps, better use paragraph range instead, not tested (setq WDRANGE (vlax-get-property (vlax-get-property (vlax-get-property MSWORDAPP 'ActiveDocument) [b]'Paragraphs[/b]) 'last)) Edited November 25, 2011 by fixo spell check Quote
fixo Posted November 25, 2011 Posted November 25, 2011 Or use something like this function, it's written in editor so test it before ;change paragraph alignment (defun ApplyAlignment (para typ / parform parrange) ;usual types are: 0 1 2 (setq parrange (vlax-get-property para 'Range)) (setq parform (vlax-get-property parrange 'ParagraphFormat)) (vlax-put-property parform 'Alignment (vlax-make-variant typ 3)) ) Quote
fixo Posted November 25, 2011 Posted November 25, 2011 Again thank you so much. OK. You're welcome Cheers ~'J'~ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.