Failed SaveAs Makes Documents Invisible (Mystery with clues)

  • Thread starter redryderridesagain
  • Start date
R

redryderridesagain

I am using Word 2003 (11.8026.6360) Sp1 (VBA)

When the execution of a "SaveAs" fails; as in the following statements;

ActiveDocument.SaveAs _
FileName:="D:\Documents and Settings\henryhiggin\My
Documents\Billminer\doppel.txt", _
FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True,
WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False, Encoding:=1252, InsertLineBreaks:=True,
AllowSubstitutions:=False, _
LineEnding:=wdCRLF
ActiveDocument.Close

The followinf statements ignore all open word docs;

passgo:
For Each docOpen In Documents
docOpen.Close SaveChanges:=wdDoNotSaveChanges
Next docOpen

The clue is that; although the documents can be closed manually; one
cannot select "SaveAs" from the "File" menu.

Is there a way of closing these stubborn files programatically?

Thanks
 
C

Cindy M -WordMVP-

I've never encountered anything like you describe, but I'm wondering
whether doing something like this would make a difference:
Dim doc as Word.document

Set doc = ActiveDocument
doc.SaveAs 'all your params here
doc.Close SaveChanges:=wdDoNotSaveChanges

First of all, you'll be sure that you're trying to close the same
document you just used SaveAs on. If you rely on ActiveDocument, that's
not 100% certain. I'm wondering if the save/close isn't hanging up, thus
blocking working with the other documents. Going this route might reveal
something you aren't seeing currently.
I am using Word 2003 (11.8026.6360) Sp1 (VBA)

When the execution of a "SaveAs" fails; as in the following statements;

ActiveDocument.SaveAs _
FileName:="D:\Documents and Settings\henryhiggin\My
Documents\Billminer\doppel.txt", _
FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True,
WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False, Encoding:=1252, InsertLineBreaks:=True,
AllowSubstitutions:=False, _
LineEnding:=wdCRLF
ActiveDocument.Close

The followinf statements ignore all open word docs;

passgo:
For Each docOpen In Documents
docOpen.Close SaveChanges:=wdDoNotSaveChanges
Next docOpen

The clue is that; although the documents can be closed manually; one
cannot select "SaveAs" from the "File" menu.

Is there a way of closing these stubborn files programatically?

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 :)
 
R

redryderridesagain

Cindy,

Thanks for the suggestion. Tried it. No change in results.

Is there some form or protection for word documents that would allow a
document to be opended but not saved - even under another name? Can
this be changed programatically?

Thanks
 
C

Cindy M -WordMVP-

Thanks for the suggestion. Tried it. No change in results.
Is there some form or protection for word documents that would allow a
document to be opended but not saved - even under another name? Can
this be changed programatically?
If they were generated in Word 2003 using IRM (Information Rights
Management) then this could be the case. It's the only one that occurs to
me, though.
I've never encountered anything like you describe, but I'm wondering
whether doing something like this would make a difference:
Dim doc as Word.document

Set doc = ActiveDocument
doc.SaveAs 'all your params here
doc.Close SaveChanges:=wdDoNotSaveChanges

First of all, you'll be sure that you're trying to close the same
document you just used SaveAs on. If you rely on ActiveDocument, that's
not 100% certain. I'm wondering if the save/close isn't hanging up, thus
blocking working with the other documents. Going this route might reveal
something you aren't seeing currently.

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 :)
 
R

redryderridesagain

Cindy said:
If they were generated in Word 2003 using IRM (Information Rights
Management) then this could be the case. It's the only one that occurs to
me, though.

I see that IRM is used a la canned management screens - can you suggest
a way of checking for the presence of "funny" permissions
programmatically. I do not see any VBA code to do this.

Thanks, as always.
 
R

redryderridesagain

I have other problems with opening word documents programmatically -
the API keeps wanting to ask me questions - I just want to try opening
the document, and if there are problems fail. Can you suggest a way of
doing this. The following code throws up dialog boxes; Thanks again.


On Error Resume Next

Documents.Open filename:=SourceFile, ConfirmConversions _
:=False, ReadOnly:=True, AddToRecentFiles:=False, PasswordDocument:="",
_
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto

If Err.Number > 0 Then
GoTo failedcopy:
End If
 
C

Cindy M -WordMVP-

I have other problems with opening word documents programmatically -
the API keeps wanting to ask me questions - I just want to try opening
the document, and if there are problems fail. Can you suggest a way of
doing this.
Not really. The Office applications weren't designed to be used this
way. See

How To Dismiss a Dialog Box Displayed by an Office Application with
Visual Basic
http://support.microsoft.com/kb/259971/


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 :)
 
R

redryderridesagain

Cindy,

I took a brief look at the example you gave. I'm not sure that the
problem is solved. I have broken down the problen somewhat as follows;

Missing Links
I'll read up on the parameters that can be passed to control this.

Password
I don't know the password, and if its password protected, I don't want
to open the file. I dont see how I can do this. Perhaps a universal
timer which cancels any open dialog boxes - have you seen anything like
this?

Printing (anticipated results)
The example sugest that I start a timer asynchronously and then if it
times out assume this has occurred because of an unanswered print box
and provide the required response to close via sendkeys (I think I go
the ist of it). I probably wont get this type of error because I wont
ask for operations like printing to be performed.

Exceptional
For one reason or another (too many uncloseable documents being one) I
will receive the "Microsoft Office Word has encountered a problem and
needs to close" errors which I presume no one can suggest a graceful
exit from.

Any suggestions or comments?

Thanks
 
R

redryderridesagain

Another description of the problem;

I have written a program to open each file in a directory tree, copy it
to a text file and extract information from it.

Out of 144,000 documents created by Word, apprximately 10 have serious
problems which cause Word to crash. On restart, I am prompted on
whether or not I want to open these files.

Any comments are welcome.
 
R

redryderridesagain

Finally, I think that I have devised a way of copying the problematic
files enough times in enough ways to get rid of the bad "joojoo". The
sequence is as follows;

- copy the file to a local directory using a File System Object copy
- open it and save as a text file
- open the text file and scan

All comments are welcome.
 
R

redryderridesagain

That does not work either as I do not have permission to copy this way
even though I can copy interactively in the usual way.
I also found that using openandrepair shows a nasty dialog box.
All suggestions welcomed at this point.
 
C

Cindy M -WordMVP-

<[email protected]>
<VA.0000c158.00d6564c@speedy>
<[email protected]>

<[email protected]>
<[email protected]>
Newsgroups: microsoft.public.word.vba.general
NNTP-Posting-Host: 80.197.76.83.cust.bluewin.ch 83.76.197.80
Lines: 1
Path: number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!TK2MSFTFEEDS01.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP03.phx.gbl
Xref: number1.nntp.dca.giganews.com microsoft.public.word.vba.general:88216
That does not work either as I do not have permission to copy this way
even though I can copy interactively in the usual way.
I also found that using openandrepair shows a nasty dialog box.
All suggestions welcomed at this point.
Since you only want to get at the text (and not page layout), you can TRY
starting with a blank document then use InsertFile to bring in the
documents. This should avoid a number of possible dialog boxes, although
I imagine you may still hit one or two snags.
Password
I don't know the password, and if its password protected, I don't want
to open the file. I dont see how I can do this. Perhaps a universal
timer which cancels any open dialog boxes - have you seen anything like
this?
I believe this is one of the things that solution would handle. But the
timer should NOT be asynchronous (something you mention in another
remark). FWIW, I seem to recall DSOFile can tell you whether a document
contains passwords (search that on msdn AND on word.mvps.org).

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 :)
 
R

redryderridesagain

Cindy,

Thanks for your persistance. I'll try the reference to "DSOFile" below.
In the meantime, it seems that the unclosable, unsaveasable document is
associated with the following error;
run-time error '5096'

can't figure that one out - can you?

Thanks
 
C

Cindy M -WordMVP-

run-time error '5096'
can't figure that one out - can you?
Not without any error.description information. Word/Office
error are poorly documented...

5 and 429 are the only two I know by heart :)

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
:)
 

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