protect doc?

J

js

Hi,
if my doc is wdAllowOnlyFormFields, the .Add method will cause
DocumentBeforeClose event to fire, and won't let me open the doc,
how to fix this? thanks.

==============================================================
Set oWordApp = CreateObject("Word.Application") 'New Word.Application
Set oWordDocO = oWordApp.Documents.Add(Template:=filename,
NewTemplate:=True)
 
D

Doug Robbins - Word MVP

Do you really want to create a new template?

Use

Set oWordApp = CreateObject("Word.Application") 'New Word.Application
Set oWordDocO = oWordApp.Documents.Add(Template:=filename,
NewTemplate:=False)


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Guest

Thanks Doug,

Can you pls explain more about if NewTemplate:=True, or False what will
happen?
 
D

Doug Robbins - Word MVP

It is is set to "True" a new template is created based on the template that
is called by Template:=filename; if it is set to "False" a new document is
created based on that template. The latter is what you would normally do.

I am assuming that somewhere earlier in your code, the path and name of the
template are loaded into the variable "filename".

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

js

Thanks Doug,

How to get the form items value if the doc is protect?
I used strDoc = oWordDocO.Content, but I can't get the item values from
content property? Any ways? Please advice. Thanks again.
 
D

Doug Robbins - Word MVP

If the values that you want are in formfields, use the .Result property of
each formfield.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

js

Thanks for the help.

How to how where (the position of the form in original doc) to output the
formfields?

for example, oWordDocO.Content only return the text, is it only way just
append the formfields at the end of the content? I want to get the original
layout as well, oWordDocO.Content + formfields in they original position?
is it possible?
 
D

Doug Robbins - Word MVP

Please explain exactly what it is that you are trying to do so that you will
get the most appropriate advice.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top