PiedPiper70
Registered User.
- Local time
- Today, 07:59
- Joined
- Oct 21, 2012
- Messages
- 115
I have used Automation a lot to programmatically create documents from word templates. This worked fine in Office 2003. It was still fine using A2010 plus Word 2003.
Now I'm trying to upgrade to Word 2010 and I'm getting an issue I don't understand. Here's a simplified code fragment:
Dim wordobj As Word.Application
Set wordobj = CreateObject("Word.Application")
wordobj.Documents.Open "c:\users\dave.k2\desktop\TestTemplate.dotx"
wordobj.ActiveDocument.SaveAs "c:\users\dave.k2\desktop\TestDoc.docx"
wordobj.Quit
I've created a simple Hello World template, the code runs without error but the resulting file won't open, and the error message is - The file Test.docx cannot be opened because there are problems with the contents.
Something's not right but I can't see it for looking. Any ideas please.
Thanks
Dave
Now I'm trying to upgrade to Word 2010 and I'm getting an issue I don't understand. Here's a simplified code fragment:
Dim wordobj As Word.Application
Set wordobj = CreateObject("Word.Application")
wordobj.Documents.Open "c:\users\dave.k2\desktop\TestTemplate.dotx"
wordobj.ActiveDocument.SaveAs "c:\users\dave.k2\desktop\TestDoc.docx"
wordobj.Quit
I've created a simple Hello World template, the code runs without error but the resulting file won't open, and the error message is - The file Test.docx cannot be opened because there are problems with the contents.
Something's not right but I can't see it for looking. Any ideas please.
Thanks
Dave