BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Opening a template in Word

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Bob Berry
Guest





PostPosted: Mon Apr 18, 2005 4:04 pm    Post subject: Opening a template in Word Reply with quote



D7; Win2K

I want to open a template from Delphi and get a new document. I adopted the
code that Jim Muir provided in response to Crazy Horse's question on 3/25.
How do I modify that code so that I do not open the template for editing.

Also, where is the Help documentation for this stuff. TWordApplication is
nowhere to be found (by me).

Thanks.


Back to top
Steve M
Guest





PostPosted: Tue Apr 19, 2005 1:35 am    Post subject: Re: Opening a template in Word Reply with quote



Hello Bob,

as I mentioned in my other post, I use VBAWRD8.HLP which has all the lowdown,
although it's in VB form but it's fairly easy to see how it works in Delphi.
So I'd try and get hold of a copy of that. Somebody else might have a better
idea.

Steve

Quote:
D7; Win2K

I want to open a template from Delphi and get a new document. I
adopted the code that Jim Muir provided in response to Crazy Horse's
question on 3/25. How do I modify that code so that I do not open the
template for editing.

Also, where is the Help documentation for this stuff.
TWordApplication is nowhere to be found (by me).

Thanks.





Back to top
Bob Berry
Guest





PostPosted: Tue Apr 19, 2005 2:02 am    Post subject: Re: Opening a template in Word Reply with quote



Steve, thanxabunsch for the response.

"Steve M" <spamyenotsteve (AT) letyenotspamsilverlink (DOT) co.uk> wrote

Quote:
Hello Bob,

as I mentioned in my other post, I use VBAWRD8.HLP which has all the
lowdown,
although it's in VB form but it's fairly easy to see how it works in
Delphi.
So I'd try and get hold of a copy of that. Somebody else might have a
better
idea.

Steve

D7; Win2K

I want to open a template from Delphi and get a new document. I
adopted the code that Jim Muir provided in response to Crazy Horse's
question on 3/25. How do I modify that code so that I do not open the
template for editing.

Also, where is the Help documentation for this stuff.
TWordApplication is nowhere to be found (by me).

Thanks.







Back to top
Bob Berry
Guest





PostPosted: Tue Apr 19, 2005 4:17 am    Post subject: Re: Opening a template in Word Reply with quote

I have now solved all the problems (with the help of folks in this
newsgroup) except one: I cannot open the template file. I have checked the
path and filename carefully and it should work, but like Crazy Horse re 3/25
post, it says it is not found. Code is below. Can someone please tell me
why this doesn't work? The file gets copied properly, but the Open fails.
However, if I set ovFormat := wdOpenFormatAuto, it opens fine, just not as a
template in a new document.

with waWordapp do
begin
tpath :=
IncludeTrailingPathDelimiter(Options.DefaultFilePath[wdUserTemplatesPath]);
if not FileExists(tpath + 'test.dot') then
if not CopyFile(PChar(IncludeTrailingPathDelimiter(common_files_path)
+ 'toolstest.dot'),
PChar(tpath + 'test.dot'), False) then
begin
MessageDlg('Create a new libretto in Word failed', mtError, [mbOK],
0);
Exit;
end;
ov_filename := tpath + 'test.dot';

ovConfirmConversions := False;
ovReadOnly := False; //possibility
ovAddToRecentFiles := False;
ovPasswordDocument := '';
ovPasswordTemplate := '';
ovRevert := False;
ovWritePasswordDocument := '';
ovWritePasswordTemplate := '';
ovFormat := wdOpenFormatTemplate;
ovEncoding := '';
ovVisible := True;
Connect;
Visible:= true;

Documents.Open(ov_filename,ovConfirmConversions,ovReadOnly,ovAddToRecentFile
s,ovPasswordDocument,ovPasswordTemplate,

ovRevert,ovWritePasswordDocument,ovWritePasswordTemplate,ovFormat,ovEncoding
,ovVisible);



"Bob Berry" <callbob (AT) paymentsinhand (DOT) com> wrote

Quote:
D7; Win2K

I want to open a template from Delphi and get a new document. I adopted
the
code that Jim Muir provided in response to Crazy Horse's question on 3/25.
How do I modify that code so that I do not open the template for editing.

Also, where is the Help documentation for this stuff. TWordApplication is
nowhere to be found (by me).

Thanks.





Back to top
Steve M
Guest





PostPosted: Tue Apr 19, 2005 12:17 pm    Post subject: Re: Opening a template in Word Reply with quote

I think you should use the Add method which applies to Documents (the Documents
collection property of WordApplication, I think)

Syntax

expression.Add(Template, NewTemplate)

expression Required. An expression that returns a Documents object.

Template Optional Variant. The name of the template to be used for the
new document. If this argument is omitted, the Normal template is used.

NewTemplate Optional Variant. True to open the document as a template.
The default value is False.

In your example
Documents.Add(ovFilename, ovFalse); //to create a new document based on your
test template
or
Documents.Add(ovFilename, ovTrue); //to open the template itself

--
Steve

Quote:
I have now solved all the problems (with the help of folks in this
newsgroup) except one: I cannot open the template file. I have
checked the path and filename carefully and it should work, but like
Crazy Horse re 3/25 post, it says it is not found. Code is below.
Can someone please tell me why this doesn't work? The file gets
copied properly, but the Open fails. However, if I set ovFormat :=
wdOpenFormatAuto, it opens fine, just not as a template in a new
document.

with waWordapp do
begin
tpath :=
IncludeTrailingPathDelimiter(Options.DefaultFilePath[wdUserTemplatesPa
th]);
if not FileExists(tpath + 'test.dot') then
if not
CopyFile(PChar(IncludeTrailingPathDelimiter(common_files_path)
+ 'toolstest.dot'),
PChar(tpath + 'test.dot'), False) then
begin
MessageDlg('Create a new libretto in Word failed', mtError,
[mbOK],
0);
Exit;
end;
ov_filename := tpath + 'test.dot';
ovConfirmConversions := False;
ovReadOnly := False; //possibility
ovAddToRecentFiles := False;
ovPasswordDocument := '';
ovPasswordTemplate := '';
ovRevert := False;
ovWritePasswordDocument := '';
ovWritePasswordTemplate := '';
ovFormat := wdOpenFormatTemplate;
ovEncoding := '';
ovVisible := True;
Connect;
Visible:= true;
Documents.Open(ov_filename,ovConfirmConversions,ovReadOnly,ovAddToRece
ntFile s,ovPasswordDocument,ovPasswordTemplate,

ovRevert,ovWritePasswordDocument,ovWritePasswordTemplate,ovFormat,ovEn
coding ,ovVisible);

"Bob Berry" <callbob (AT) paymentsinhand (DOT) com> wrote in message
news:4263da72$1 (AT) newsgroups (DOT) borland.com...

D7; Win2K

I want to open a template from Delphi and get a new document. I
adopted

the

code that Jim Muir provided in response to Crazy Horse's question on
3/25. How do I modify that code so that I do not open the template
for editing.

Also, where is the Help documentation for this stuff.
TWordApplication is nowhere to be found (by me).

Thanks.





Back to top
Bob Berry
Guest





PostPosted: Tue Apr 19, 2005 9:31 pm    Post subject: Re: Opening a template in Word Reply with quote

Steve,

Thanks very much for your help on this. Here is what finally worked for me:

ov_filename := tpath + 'test.dot';
ov_visible := True;
ov_newtemplate := False;
ov_documenttype := wdTypeTemplate;
Connect;
Visible:= true;
Documents.Add(ov_filename, ov_newtemplate, ov_documenttype, ovVisible);

"Steve M" <spamyenotsteve (AT) letyenotspamsilverlink (DOT) co.uk> wrote

Quote:
I think you should use the Add method which applies to Documents (the
Documents
collection property of WordApplication, I think)

Syntax

expression.Add(Template, NewTemplate)

expression Required. An expression that returns a Documents object.

Template Optional Variant. The name of the template to be used for the
new document. If this argument is omitted, the Normal template is used.

NewTemplate Optional Variant. True to open the document as a template.
The default value is False.

In your example
Documents.Add(ovFilename, ovFalse); //to create a new document based on
your
test template
or
Documents.Add(ovFilename, ovTrue); //to open the template itself

--
Steve

I have now solved all the problems (with the help of folks in this
newsgroup) except one: I cannot open the template file. I have
checked the path and filename carefully and it should work, but like
Crazy Horse re 3/25 post, it says it is not found. Code is below.
Can someone please tell me why this doesn't work? The file gets
copied properly, but the Open fails. However, if I set ovFormat :=
wdOpenFormatAuto, it opens fine, just not as a template in a new
document.

with waWordapp do
begin
tpath :=
IncludeTrailingPathDelimiter(Options.DefaultFilePath[wdUserTemplatesPa
th]);
if not FileExists(tpath + 'test.dot') then
if not
CopyFile(PChar(IncludeTrailingPathDelimiter(common_files_path)
+ 'toolstest.dot'),
PChar(tpath + 'test.dot'), False) then
begin
MessageDlg('Create a new libretto in Word failed', mtError,
[mbOK],
0);
Exit;
end;
ov_filename := tpath + 'test.dot';
ovConfirmConversions := False;
ovReadOnly := False; //possibility
ovAddToRecentFiles := False;
ovPasswordDocument := '';
ovPasswordTemplate := '';
ovRevert := False;
ovWritePasswordDocument := '';
ovWritePasswordTemplate := '';
ovFormat := wdOpenFormatTemplate;
ovEncoding := '';
ovVisible := True;
Connect;
Visible:= true;
Documents.Open(ov_filename,ovConfirmConversions,ovReadOnly,ovAddToRece
ntFile s,ovPasswordDocument,ovPasswordTemplate,

ovRevert,ovWritePasswordDocument,ovWritePasswordTemplate,ovFormat,ovEn
coding ,ovVisible);

"Bob Berry" <callbob (AT) paymentsinhand (DOT) com> wrote in message
news:4263da72$1 (AT) newsgroups (DOT) borland.com...

D7; Win2K

I want to open a template from Delphi and get a new document. I
adopted

the

code that Jim Muir provided in response to Crazy Horse's question on
3/25. How do I modify that code so that I do not open the template
for editing.

Also, where is the Help documentation for this stuff.
TWordApplication is nowhere to be found (by me).

Thanks.







Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.