Opening a document via a macro

J

John Grierson

In an AutoOpen macro I am using

Documents.Open FileName := ss

(where ss is a string containing path and file name)

However, instead of opening a new window the file is
pasted into the first document.

Advice, please and thanks, on how to force a new window to
open.

John
 
J

Jezebel

The method you're using is exactly the right one: that *should* open the
document in a new window, and I've never seen it do as you describe. Is
there some other code running (such as an AutoOpen macro) ? If you open ss
manually, does it look as you expect?
 
G

Guest

Thanks Jezebel.

Simply, an AutoOpen macro in First.dco of

ss = "C:\xx\xxx.doc"
Documents.Open FileName := ss

pastes xxx.doc into First.doc

Going manually via File | Open and browsing gives the
correct result with xxx.doc opened in a second window.

John
 
J

Jezebel

Can't reproduce the problem. Using that exact code, I get the two documents,
each in a separate window. Are you sure there are no OTHER AutoOpen
functions, either in the underlying template, or in an add-in?
 
G

Guest

Hi Jezebel,

The problem has to be something to do with the particular
file I am opening 'cos I have now tried using other files
and they open correctly in a new window.

But I cannot spot any problem in the file I want to open
and it contains no macros.

Would be pleased to send you a copy if you are interested.

Many thanks

John
 
J

Jezebel

If the document is corrupt, copy the content you need to keep to a new
document, and delete it. There's really no way to diagnose the corruption,
and nothing you can do about it anyway.
 
J

John Grierson

Hi Jezebel,

Selected and copied all of the old document to a new one
and all works.

Many thanks for the advice - had not realised that we can
have corrupt Word files.

John
 

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