필터 지우기
필터 지우기

creating word doc - setting watermark background image on main page and page numbers on the rest

조회 수: 4 (최근 30일)
Hi, has anyone done this please?
I've created a word doc using
MATLAB code
wordDoc = invoke(get(wordApp, 'Documents'), 'Add');
and have populated it with tables and images etc.
I've just gone completely thick when trying to get the page numbers and an image on the first page!
Any help (or sympathy) appreciated :-)
Cheers,
Tom

답변 (1개)

Friedrich
Friedrich 2012년 2월 13일
Hi,
one thing I do when I don't know the code for that is to let Word do a Macro and look at the generated VBA code. In that way you see the commands used to achieve what you like.
So start Word, enable Macro recording, do manually what you want, stop the Macro recording and than look at the VBA code.
This helps in 99% of the cases to get what you want.
  댓글 수: 5
tombola
tombola 2012년 2월 14일
Hey, sorry man, I just can't get this to work. I have a wordApp, wordDoc and selection object.
They're all set up fine, if I type
MATLAB code
selection.TypeText('Hello!');
Hello! is added to the word doc ok.
But if I enter:
MATLAB code
selection.HeaderFooter.Shapes.AddPicture('C:\Tom\background.png',false, true)
I get:
Attempt to reference field of non-structure array.
And if I enter:
MATLAB code
wordDoc.AttachedTemplate.BuildingBlockEntries('Plain Number 2').Insert(wordApp.Selection.Range, true)
I get:
Index exceeds matrix dimensions.
Is anything obviously wrong here please?
THANKS for all the help,
Tom
Friedrich
Friedrich 2012년 2월 14일
I am not 100% sure but maybe MATLAB cant resolve that code correctly. maybe try an invoke
invoke(selection.HeaderFooter.Shapes,'AddPicture','C:\Tom\background.png',false, true)
If this doesnt help, can you upload an example (word doc and your ML code) somewhere? So i can play around myself to get it running.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by