Freezing macro & document when opened....

G

GUNNAR BAARDSEN

Hi there.

I have made a template that contains a userform (MAIN) and some macros.
Info from this userform is saved to/loaded from this template.

A button on this userform executes some commands to open another document
(based on a different template).

But when I have opened this other document, I have noe edit/navigating
access to the document.
The document freezes, and is not editable until I have closed my MAIN
userform.

How can I fix this problem, so that I can have several documents open at the
same time?? This must surely be possible.

An other problem with this, is that after I have opened this other document
ONCE, and try to open it again from the userform, IT WILL NOT open.
It generates a run-time error '5151':
The document name or path is not valid.
Try one or more of the following:
* Check the path to make sure it was typed correctly.
* On the File menu, click Open. Search for the file using this dialog box.

The document I'm trying to open (again) IS at the same location AND have the
same filename (I've not altered the code between this two tryouts - of
course :)

And the strange part is if I close the macro, and closes the template (and
Word 2002), and then loads the template, runs the macro again, push the
button that opens my second document - it opens!!!!
But the document is still not editable - like before.

To open the second document (from the button on the userform), I'm using
this line of code:

Documents.Add Template:="Something.dot"

Do I have to write some command/line of code that puts the focus on the
newly opened document or what??

Hoping some of you can give me some answers here.

Gunnar
 
H

Howard Kaikow

Unless you make the userform modeless, you cannot do anything outside of the
userform until the userform is closed.
 
G

GUNNAR BAARDSEN

Hi again.

Thanks for the info.
This fixed ONE of my problems.

But my main problem now is that I can't open a template using
Documents.Add Template:="Test.dot"

The FIRST thime I run my macro (VBA code), this works.
But the next time, I get the run-time error 5151:

The document name or path is not valid.
Try one or more of the following:
* Check the path to make sure it was typed correctly.
* On the File menu, click Open. Search for the file using this dialog box.

The document I'm trying to open (again) IS at the same location AND have the
same filename.
And the strange part is if I close the macro, and closes the template that
holds this macro (and
Word 2002), and then loads the template, runs the macro again, runs the
macro with my line

Documents.Add Template:="Test.dot"

it opens!!!!

Do I need to Close the document that I have added with the help of my
template in any way? Is it maybe still in my memory in somehow??

I have looked thru the VBA help, searched a lot of forums and news groups,
and I can't find any help on this matter.
Please help and advise.

Thanx alot.
Gunnar
 

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