Michael Sterling
asked on
Add object Field
in D7 using a TWPRichText component there is a line of code that will allow you to insert an 'OBJECT' type into the current list of fields in the document you are working with:
Editor.InputField('*', 'Subreport', 'OBJECT'); for example, (yes i'm trying to add document b to document a).
is there an equivalent line of code when using TWordApplication and TWordDocument on an OLEContainer.
Editor.InputField('*', 'Subreport', 'OBJECT'); for example, (yes i'm trying to add document b to document a).
is there an equivalent line of code when using TWordApplication and TWordDocument on an OLEContainer.
ASKER
i believe that it is. is there a way to choose the exact location within the main document where i want to open (place) the subdocument?
first of all you can change wrdApp to OleConatiner.OleObject in previuos sample.
exact position... i guess it's cursor position but i'll check it
ziolko.
exact position... i guess it's cursor position but i'll check it
ziolko.
yup subdocument is inserted at cursor position but you have to remove wrdDoc.Select;
ziolko.
ziolko.
ASKER
ok when you say above: "...you can change..." are you saying that i have to or that it is an option. i haven't tried it yet just curious. and yes please if you find any source of info on how to manipulate or insert at the point of or even set the position of the cursor, please point me in that direction.
>>ok when you say above: "...you can change..."
in my sample i open word by calling CreateOleObject not via OleContainer but OleContainer.OleObject is equivalent to wrdApp in my sample.
so:
wrdDoc := wrdApp.Documents.Add() = OleContainer.OleObject.Doc uments.Add ()
>>if you find any source of info on how to manipulate or insert at the point of or even set the position of the cursor, please point me in that direction
sure but not today :) it's midnight and that means that in 6 hours i've got to be at work:)
ziolko.
in my sample i open word by calling CreateOleObject not via OleContainer but OleContainer.OleObject is equivalent to wrdApp in my sample.
so:
wrdDoc := wrdApp.Documents.Add() = OleContainer.OleObject.Doc
>>if you find any source of info on how to manipulate or insert at the point of or even set the position of the cursor, please point me in that direction
sure but not today :) it's midnight and that means that in 6 hours i've got to be at work:)
ziolko.
ASKER
sounds good thanks for your help. get some sleep...
you can try with one of these:
OleContainer.OleObject.Sel ection.Mov e()
OleContainer.OleObject.Sel ection.Mov eStart()
OleContainer.OleObject.Sel ection.Mov eEnd()
OleContainer.OleObject.Sel ection.Mov eLeft()
OleContainer.OleObject.Sel ection.Mov eRight()
OleContainer.OleObject.Sel ection.Mov eUp()
OleContainer.OleObject.Sel ection.Mov eDown()
sample move up 3 lines:
OleContainer.OleObject.Sel ection.Mov eUp(wdLine , 3);
ziolko.
OleContainer.OleObject.Sel
OleContainer.OleObject.Sel
OleContainer.OleObject.Sel
OleContainer.OleObject.Sel
OleContainer.OleObject.Sel
OleContainer.OleObject.Sel
OleContainer.OleObject.Sel
sample move up 3 lines:
OleContainer.OleObject.Sel
ziolko.
ASKER
ok...sounds good. is there anyway to catch when a document is being edited? something like OnDocumentEdit similar?
word.application COM server has DocumentChange event, do you want to use from OleCaontainer?.
ziolko.
ziolko.
ASKER
yes that's exactly where i want to use it from. inside an OLEContainer is where my wordApp / wordDoc is sitting so that would be perfect.
it's not single-line solution, some code has to be written i'll try to find some time over weekend
ziolko.
ziolko.
ASKER
ok thank you. your time and effort are appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
...you'll need
uses WordXP, OleServer, ActiveX;
ziolko.
uses WordXP, OleServer, ActiveX;
ziolko.
why delete?? original Q was about inserting sub-document I provided suggestion which was intially accepted {http:#19703736} then was follow-up question about moving cursor within word doc again initially accepted {http:#19710746} then was second follow-up question and once again i provided suggestion {http:#19728432} last suggestion is not solving problem, that's true, but it's second follow-up and now delete request? without even a single word why? i don't get it
ziolko.
ziolko.
ASKER
i was able to solve my problem using a combination of some of ziolko's suggestions and my own exploration / discoveries. so i will ask that it be closed indicating this.
uses ComObj, WordXP;
procedure TForm1.Button1Click(Sender
var wrdApp, wrdDoc: Variant;
begin
wrdApp := CreateOleObject('Word.Appl
wrdApp.Visible := True;
wrdDoc := wrdApp.Documents.Add();
wrdDoc.Select;
wrdDoc.ActiveWindow.View.t
wrdDoc.Subdocuments.AddFro
end;
ziolko.