Custom TaskPanes

J

Jan Kucera

Hi,
is there any way how to provide custom taskpane in my document template
without requesting .NET to be installed on the client machine?

(eg. to code it in VBA)


Thanks,
Jan
 
J

Jean-Guy Marcil

Jan Kucera was telling us:
Jan Kucera nous racontait que :
Hi,
is there any way how to provide custom taskpane in my document
template without requesting .NET to be installed on the client
machine?
(eg. to code it in VBA)

It is not possible through VBA.

But, you may want to use Smart Documents (XML), depending on what you wanted
your task pane to do.

See this MSDN article:
http://tinyurl.com/9jg6w


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jan Kucera

It is not possible through VBA.

But, you may want to use Smart Documents (XML), depending on what you
wanted your task pane to do.


Hi, thank you for reply. I want just to have some common controls on the
taskpane, with ability to change them dynamically. I have the 2003 Smart
Document SDK with me, however I am note able to make the samples work in
Office 2007. I need some solution which will work in 2003 as well as in 2007
and without need to install anything on the client. If it is not possible in
SmartDocument, I will have to create it in VBA and do the rest with Win32
API... or any other idea?
Thanks, Jan.
 
C

Cindy M.

Hi Jan,
I want just to have some common controls on the
taskpane, with ability to change them dynamically. I have the 2003 Smart
Document SDK with me, however I am note able to make the samples work in
Office 2007. I need some solution which will work in 2003 as well as in 2007
and without need to install anything on the client. If it is not possible in
SmartDocument, I will have to create it in VBA and do the rest with Win32
API... or any other idea?
You aren't going to find any solution meeting these criteria that you can
implement the same way in both versions of Word. Anything for Word 2003 will
require installing something on the client, including a SmartDocument approach.

Without your stipulation about installing something on the client, I'd have
suggested taking a look at VSTO.

Some people have tried to "fudge" it, using some kind of form and the Windows
API, but from what I've been able to understand of those conversations (mostly
in office.developer.automation and word.vba.general), what they've come up with
has been "finicky" and not entirely satisfying.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
J

Jan Kucera

Hi Cindy,
thank you for your answer again. Be sure I love VS and .NET ;-) but all
these silly restrictions are unfortunately not set by me. However I've
managed to bypass the request of dynamical controls, so I'm going to create
the form in VBA and include it in the template.
Before I will be able to try it, will the template be loaded if it is
referenced using URL? Or UNC is requested?

Thanks,
Jan
 
C

Cindy M.

Hi Jan,
I'm going to create
the form in VBA and include it in the template.
Before I will be able to try it, will the template be loaded if it is
referenced using URL? Or UNC is requested?
Depends on what you mean by "loaded" :) If you have a URL to a template,
it will open the template rather than create a new document from it. To
get a new document, the URL would have to point to a shortcut to a
template (shortcut as in like a shortcut on a desktop). Or it would have
to execute script to force a new document from the template (automate
Word and Documents.Add method).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

Jan Kucera

Depends on what you mean by "loaded" :) If you have a URL to a template,
it will open the template rather than create a new document from it. To
get a new document, the URL would have to point to a shortcut to a
template (shortcut as in like a shortcut on a desktop). Or it would have
to execute script to force a new document from the template (automate
Word and Documents.Add method).

Actually as you wrote it I've realized that I need this too.
Okay, so when I want to create new document based on template and I have the
URL to template, this will open the template itself? I'm not sure if I will
be able to create shortcut since I don't know the URL untill runtime, but I
definetily will be able to write a clientscript which could do that. My
current script for regular documents looks like:

Content-Type: text/plain
Content-Disposition: inline;filename=Document.vbs

Set app = Wscript.CreateObject("Word.Application")
app.Visible = True
app.Documents.Open "URLtoDocument"

So you suggest me just to use app.Documents.Add instead of
app.Documents.Open? That seems I could use Add for regular documents too and
have only one script, couldn't I?

But what I was really asking for the first time was if the regular document
opened with the method above can have a template attached also using the URL
and if the template will be downloaded during opening of the document?

Thank you,
Jan
 
C

Cindy M.

Hi Jan,
So you suggest me just to use app.Documents.Add instead of
app.Documents.Open? That seems I could use Add for regular documents too and
have only one script, couldn't I?
Yes :)
But what I was really asking for the first time was if the regular document
opened with the method above can have a template attached also using the URL
and if the template will be downloaded during opening of the document?
It certainly wouldn't be downloaded. I'm afraid you'll have to test how well
"attached" will work. I can't test that, here.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
J

Jan Kucera

Cindy M. said:
Hi Jan,

It certainly wouldn't be downloaded. I'm afraid you'll have to test how
well
"attached" will work. I can't test that, here.

Okay, that sounds a little bit challenging ;-) .... how well could it be?
Are there more ways for template being attached?
By the way, if it would be an UNC path, will it solve the problem if I
couldn't find any solution?

Jan.
 
C

Cindy M.

Hi Jan,
Okay, that sounds a little bit challenging ;-) .... how well could it be?
Are there more ways for template being attached?
By the way, if it would be an UNC path, will it solve the problem if I
couldn't find any solution?
I can't test here because I don't have an Intranet available.

Originally, Word wasn't designed to work with URLs. Over time, Microsoft has
enabled them, bit by bit; for some things they work, for others not. That's
why I said you'd have to try it :) About the downloading: more recent
versions of Word do provide a "cache" (Tools/Options/Save) for off-line
templates and such. But that's not the same as down-loading.

Templates can only truly be attached the one way. Anything else won't be
document-specific (or would require relying on events such as Document_Change
to make sure it's available only in certain documents).

A UNC path should solve the problem, for sure (as long as the network isn't
down <g>)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

Jan Kucera

Nice to read you again, Cindy ;-)

Cindy M. said:
Hi Jan,

Originally, Word wasn't designed to work with URLs. Over time, Microsoft
has
enabled them, bit by bit; for some things they work, for others not.
That's
why I said you'd have to try it :) About the downloading: more recent
versions of Word do provide a "cache" (Tools/Options/Save) for off-line
templates and such. But that's not the same as down-loading.

Templates can only truly be attached the one way. Anything else won't be
document-specific (or would require relying on events such as
Document_Change
to make sure it's available only in certain documents).

A UNC path should solve the problem, for sure (as long as the network
isn't
down <g>)

What I've tried is to attach the template by manually typing the URL into
template dialog box. It was loaded. But, this was the last time I saw it to
be loaded. ;-) I tried to put the URL into xml and as you wrote it wasn't
loaded, but there was no attempt to load anything over http I modified in
the template dialog.

But I've got an idea. I have to open the document using client script,
because of the WebDAV issues I wrote some time ago (and which I'm still
looking answer for, so if you know a guy who would know what's up I would
welcome to have this corrected before the upcoming release of Office), so I
could just app.Documents.Add to open the document and then attach the
template to it in the same script (what's the method please?). I hope this
will work, since otherwise I'm out of http ideas.. ;-)

Thanks,
Jan
 
C

Cindy M.

Hi Jan,
so I
could just app.Documents.Add to open the document and then attach the
template to it in the same script (what's the method please?).
Set doc = app.Documents.Add
doc.AttachedTemplate = "Full path to template file"

And thanks very much for the detailed description of what you tried, and
how it (didn't) worked.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
J

Jan Kucera

Hi Cindy,
no luck. First of all, I can't use Documents.Add to open a regular document
because this opens a new document based on that one instead of the document
itself, at least when opening xml format over http. On the other hand I
understand this, since I read that any XML document can be used as a
document template. So I have to open documents using Documents.Open since
almost all of them are in XML and because I have only one template, I will
solve this individually.

I have tried to attach the template using doc.AttachedTemlpate = "http...".
It wasn't loaded and no attempt to download.
I also tried doc.AttachedTemplate = app.Documents.Open("http..."). The
template was attached to the document (I found the correct url in the
template dialog box). But there are two big problems I face. The first one -
the template was open. I don't know how to force Word to load/open a
document and do not show it. The worse one, the template events are not
called, mainly Document_Open, which I understand, but need them to be
called.

If you don't have any idea my last one is to download a copy of the template
and store it in the local templates directory, prefferably with Word's
methods and to the documents just point to the template's filename without
path. Is it possible that this would fail because of security restrictions
on that directory?

Thank you,
Jan.
 
J

Jan Kucera

Is it at least possible to get the default template directory? I tried to
download the template and put it to the the Application.StartupPath
directory using the script. It was loaded, but the document did not find it,
actually I put the "Template.dot" into the xml attached template element,
nothing happened and when I checked the template dialog box,
C:\Windows\System32\Template.dot was there....
 
C

Cindy M.

Hi Jan,
The first one -
the template was open. I don't know how to force Word to load/open a
document and do not show it. The worse one, the template events are not
called, mainly Document_Open, which I understand, but need them to be
called.
The only other thing that occurs to me, given that Documents.Open worked to
"attach" the template would be to try loading it as an Addin (see the Addins
collection), then attaching it. When you load the template, it's likely that
AutoExec will be executed. But certainly nothing will be run when you *attach*
the template.
If you don't have any idea my last one is to download a copy of the template
and store it in the local templates directory, prefferably with Word's
methods and to the documents just point to the template's filename without
path. Is it possible that this would fail because of security restrictions
on that directory?
There can certainly be all kinds of issues if you download files to the users
machine. And your first obstacle is going to be determining which directory is
the designated Templates directory. And yes, there certainly could be security
restrictions on the directory.

You've never really described what you're trying to do, in general terms, so
it's difficult to give you any alternate ideas. I'm beginning to think you may
need to consider "embedding" Word in a Windows Form (.NET), or a browser window
using some kind of OLE control. Or, if this solution is for a particular
client, you need to work out folder/Registryy access options with the client.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
J

Jan Kucera

Hi Cindy!
Good news, I have worked out the most succesfull solution. That is, managed
to hide document window and run the macro manually, here it is:

Set app = Wscript.CreateObject("Word.Application")
app.Visible = True

Set doc = app.Documents.Open("http..XmlDocument")
doc.AttachedTemplate =
app.Documents.Open("http..Template",,true,false,,,false,,,,,false) //read
only, not in recent list, not visible, not revert
doc.RunAutoMacro 2

Set app = nothing

I think I will leave this that way. Happy to avoid manually downloading
files to the computer.
I'm sorry if I haven't said what I'm trying to do. I have XML documents on
the web server with attached template which is also on the server. All I
need is to open them. I can't just put a hyperlink to them, because Word
would not try to open it for read/write, which I also need.
In the template, there is a form which just writes some pieces of text to
the documents and on the server side, the document is taken and these pieces
replaced with actual data.
This is a project for government and unfortunately the first and top
requirment is to install anything on the clients.

Thank you for your support and help,
Jan
 
C

Cindy M.

Hi Jan,
Is it at least possible to get the default template directory? I tried to
download the template and put it to the the Application.StartupPath
directory using the script. It was loaded, but the document did not find it,
actually I put the "Template.dot" into the xml attached template element,
nothing happened and when I checked the template dialog box,
C:\Windows\System32\Template.dot was there....
Only if you automate the Word object model. "Long ago" you could read this
information from the Registry. For security reasons, that's no longer possible.
There is a default installation path, but most companies will re-route it.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
C

Cindy M.

Hi Jan,
Good news, I have worked out the most succesfull solution. That is, managed
to hide document window and run the macro manually, here it is:

Set app = Wscript.CreateObject("Word.Application")
app.Visible = True

Set doc = app.Documents.Open("http..XmlDocument")
doc.AttachedTemplate =
app.Documents.Open("http..Template",,true,false,,,false,,,,,false) //read
only, not in recent list, not visible, not revert
Glad this is working for you :) One thing, though (just so you don't deploy
and then have to go back to the drawing board): The document you're attaching
as a template will probably be accessible through the Windows menu if this is
Office 2003.

And you do need to have some way to explicitly UNLOAD (close) it. Especially
if this is NOT 2003. In earlier versions this was the source of some really
bad memory leaks and other problems.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

Jan Kucera

Hi Cindy.

Cindy M. said:
Glad this is working for you :) One thing, though (just so you don't
deploy
and then have to go back to the drawing board): The document you're
attaching
as a template will probably be accessible through the Windows menu if this
is
Office 2003.

Okay, thank you for this hint, however the template only contains the macros
to connect to the server and it is accessed using plain GET so if it gets
broken it can't be saved back. Maybe I could add Saved = True on template's
Document_Close to avoid unexpected questions during save or exiting the
Word.
And you do need to have some way to explicitly UNLOAD (close) it.
Especially
if this is NOT 2003. In earlier versions this was the source of some
really
bad memory leaks and other problems.

This is far worse. Actually the files which I open and which uses the
template are in WordML, so I expect them to be openeed at least in 2003
version. ;-) However as a developer I have the responsibility for this and
if you know how can I close it explicitly when it is not needed, I will do
it.

Thank you,
Jan
 

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