From: Ed from AZ on
I'm working in Vista with Word and Excel 2007. I'm writing a macro in
Excel that opens and reads a file using FSO, creates a new Word doc
and writes the file data into the doc, and then saves the doc so I can
use Word ranges to grab the data and write it into the Excel file.

Every time the code gets to the SaveAs command for the Word document,
the code balks and throws a run-time error. If I click Debug and hit
either F8 or F5, the command immediately executes and the code
continues running just fine. The error is:
-2147417851 (80010105)
Method 'SaveAs' of object '_Docuement' failed

I tried adding Sleep in case there was something going on that wasn't
finished, and even threw in a DoEvents. No joy! If anyone can help
me over this hump, I'd greatly appreciate it!

Thanks!
Ed

strPath = Left(strFile, Len(strFile) - 4)
Sleep (15000)
DoEvents
objDoc.SaveAs strPath & ".docx" 'Both statements throw the error
'objWd.Documents(objWd.Documents.Count).SaveAs Filename:=strPath &
".doc"
Sleep (15000)
From: Doug Robbins - Word MVP on
What does strFile contain, or more specifically, what is its extension. If
the extension is docx, your code will be trying the save a file with a name
that has two periods before the extension.

Try objDoc.SaveAs strPath & "docx"

--
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, originally posted via msnews.microsoft.com

"Ed from AZ" <prof_ofwhat(a)yahoo.com> wrote in message
news:9bff5e4b-2efa-4b4f-9a6f-8e49a58cf89a(a)g10g2000yqh.googlegroups.com...
> I'm working in Vista with Word and Excel 2007. I'm writing a macro in
> Excel that opens and reads a file using FSO, creates a new Word doc
> and writes the file data into the doc, and then saves the doc so I can
> use Word ranges to grab the data and write it into the Excel file.
>
> Every time the code gets to the SaveAs command for the Word document,
> the code balks and throws a run-time error. If I click Debug and hit
> either F8 or F5, the command immediately executes and the code
> continues running just fine. The error is:
> -2147417851 (80010105)
> Method 'SaveAs' of object '_Docuement' failed
>
> I tried adding Sleep in case there was something going on that wasn't
> finished, and even threw in a DoEvents. No joy! If anyone can help
> me over this hump, I'd greatly appreciate it!
>
> Thanks!
> Ed
>
> strPath = Left(strFile, Len(strFile) - 4)
> Sleep (15000)
> DoEvents
> objDoc.SaveAs strPath & ".docx" 'Both statements throw the error
> 'objWd.Documents(objWd.Documents.Count).SaveAs Filename:=strPath &
> ".doc"
> Sleep (15000)

From: Ed from AZ on
Hi, Doug.

No - the end of strFile is ".xml". So it's a clean string without the
"."

And when it errors and I Debug, then F8 or F5, it saves fine, with no
changes to the file path and name strings.

Ed


On Mar 23, 2:22 pm, "Doug Robbins - Word MVP"
<d...(a)REMOVECAPSmvps.org> wrote:
> What does strFile contain, or more specifically, what is its extension.  If
> the extension is docx, your code will be trying the save a file with a name
> that has two periods before the extension.
>
> Try objDoc.SaveAs strPath & "docx"
>
> --
> 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, originally posted via msnews.microsoft.com
>
> "Ed from AZ" <prof_ofw...(a)yahoo.com> wrote in messagenews:9bff5e4b-2efa-4b4f-9a6f-8e49a58cf89a(a)g10g2000yqh.googlegroups.com...
>
>
>
> > I'm working in Vista with Word and Excel 2007.  I'm writing a macro in
> > Excel that opens and reads a file using FSO, creates a new Word doc
> > and writes the file data into the doc, and then saves the doc so I can
> > use Word ranges to grab the data and write it into the Excel file.
>
> > Every time the code gets to the SaveAs command for the Word document,
> > the code balks and throws a run-time error.  If I click Debug and hit
> > either F8 or F5, the command immediately executes and the code
> > continues running just fine.  The error is:
> > -2147417851 (80010105)
> > Method 'SaveAs' of object '_Docuement' failed
>
> > I tried adding Sleep in case there was something going on that wasn't
> > finished, and even threw in a DoEvents.  No joy!  If anyone can help
> > me over this hump, I'd greatly appreciate it!
>
> > Thanks!
> > Ed
>
> > strPath = Left(strFile, Len(strFile) - 4)
> > Sleep (15000)
> > DoEvents
> > objDoc.SaveAs strPath & ".docx"  'Both statements throw the error
> > 'objWd.Documents(objWd.Documents.Count).SaveAs Filename:=strPath &
> > ".doc"
> > Sleep (15000)- Hide quoted text -
>
> - Show quoted text -
From: Doug Robbins - Word MVP on
You may need to set the SaveFormat to wdFormatDocument as you are converting
from one format to another

--
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, originally posted via msnews.microsoft.com

"Ed from AZ" <prof_ofwhat(a)yahoo.com> wrote in message
news:f57620ea-3a7c-46c7-908f-c384ae97801a(a)y17g2000yqd.googlegroups.com...
> Hi, Doug.
>
> No - the end of strFile is ".xml". So it's a clean string without the
> "."
>
> And when it errors and I Debug, then F8 or F5, it saves fine, with no
> changes to the file path and name strings.
>
> Ed
>
>
> On Mar 23, 2:22 pm, "Doug Robbins - Word MVP"
> <d...(a)REMOVECAPSmvps.org> wrote:
>> What does strFile contain, or more specifically, what is its extension.
>> If
>> the extension is docx, your code will be trying the save a file with a
>> name
>> that has two periods before the extension.
>>
>> Try objDoc.SaveAs strPath & "docx"
>>
>> --
>> 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, originally posted via msnews.microsoft.com
>>
>> "Ed from AZ" <prof_ofw...(a)yahoo.com> wrote in
>> messagenews:9bff5e4b-2efa-4b4f-9a6f-8e49a58cf89a(a)g10g2000yqh.googlegroups.com...
>>
>>
>>
>> > I'm working in Vista with Word and Excel 2007. I'm writing a macro in
>> > Excel that opens and reads a file using FSO, creates a new Word doc
>> > and writes the file data into the doc, and then saves the doc so I can
>> > use Word ranges to grab the data and write it into the Excel file.
>>
>> > Every time the code gets to the SaveAs command for the Word document,
>> > the code balks and throws a run-time error. If I click Debug and hit
>> > either F8 or F5, the command immediately executes and the code
>> > continues running just fine. The error is:
>> > -2147417851 (80010105)
>> > Method 'SaveAs' of object '_Docuement' failed
>>
>> > I tried adding Sleep in case there was something going on that wasn't
>> > finished, and even threw in a DoEvents. No joy! If anyone can help
>> > me over this hump, I'd greatly appreciate it!
>>
>> > Thanks!
>> > Ed
>>
>> > strPath = Left(strFile, Len(strFile) - 4)
>> > Sleep (15000)
>> > DoEvents
>> > objDoc.SaveAs strPath & ".docx" 'Both statements throw the error
>> > 'objWd.Documents(objWd.Documents.Count).SaveAs Filename:=strPath &
>> > ".doc"
>> > Sleep (15000)- Hide quoted text -
>>
>> - Show quoted text -

From: Ed from AZ on
On Mar 23, 2:47 pm, "Doug Robbins - Word MVP"
<d...(a)REMOVECAPSmvps.org> wrote:
> You may need to set the SaveFormat to wdFormatDocument as you are converting
> from one format to another

I'll give that a try, Doug. I'm not sure, though - I am not opening
the XML in Word and resaving as a doc. The XML is opened in FSO and
read, a new do is created using the Word app, contents of the XML are
pasted into the new unsaved Word doc, and then I'm trying to save the
new doc.

Is there some interaction between Word and FSO that I might not be
aware of that's causing this?
Ed


>
> --
> 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, originally posted via msnews.microsoft.com
>
> "Ed from AZ" <prof_ofw...(a)yahoo.com> wrote in messagenews:f57620ea-3a7c-46c7-908f-c384ae97801a(a)y17g2000yqd.googlegroups.com...
>
>
>
> > Hi, Doug.
>
> > No - the end of strFile is ".xml".  So it's a clean string without the
> > "."
>
> > And when it errors and I Debug, then F8 or F5, it saves fine, with no
> > changes to the file path and name strings.
>
> > Ed
>
> > On Mar 23, 2:22 pm, "Doug Robbins - Word MVP"
> > <d...(a)REMOVECAPSmvps.org> wrote:
> >> What does strFile contain, or more specifically, what is its extension..
> >> If
> >> the extension is docx, your code will be trying the save a file with a
> >> name
> >> that has two periods before the extension.
>
> >> Try objDoc.SaveAs strPath & "docx"
>
> >> --
> >> 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, originally posted via msnews.microsoft.com
>
> >> "Ed from AZ" <prof_ofw...(a)yahoo.com> wrote in
> >> messagenews:9bff5e4b-2efa-4b4f-9a6f-8e49a58cf89a(a)g10g2000yqh.googlegroups.com...
>
> >> > I'm working in Vista with Word and Excel 2007.  I'm writing a macro in
> >> > Excel that opens and reads a file using FSO, creates a new Word doc
> >> > and writes the file data into the doc, and then saves the doc so I can
> >> > use Word ranges to grab the data and write it into the Excel file.
>
> >> > Every time the code gets to the SaveAs command for the Word document,
> >> > the code balks and throws a run-time error.  If I click Debug and hit
> >> > either F8 or F5, the command immediately executes and the code
> >> > continues running just fine.  The error is:
> >> > -2147417851 (80010105)
> >> > Method 'SaveAs' of object '_Docuement' failed
>
> >> > I tried adding Sleep in case there was something going on that wasn't
> >> > finished, and even threw in a DoEvents.  No joy!  If anyone can help
> >> > me over this hump, I'd greatly appreciate it!
>
> >> > Thanks!
> >> > Ed
>
> >> > strPath = Left(strFile, Len(strFile) - 4)
> >> > Sleep (15000)
> >> > DoEvents
> >> > objDoc.SaveAs strPath & ".docx"  'Both statements throw the error
> >> > 'objWd.Documents(objWd.Documents.Count).SaveAs Filename:=strPath &
> >> > ".doc"
> >> > Sleep (15000)- Hide quoted text -
>
> >> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -