locked
DDE (Automation) Access to Word RRS feed

  • Question

  • I have a VBA macro in MS Access that rolls through my database and creates a MS Word document. This worked for years with Office XP. As part of the macro, I create a Text Box in the header of the Word document, format it, then convert it to a Frame so I can specify Outside (through code) for duplex printing.

    Since my upgrade to Office 2010, the "WordApp.ShapeRange(1).ConvertToFrame" command constantly fails with "Error 4652 - Wrong drawing object for this command".

    I have been up and down the help files and cannot find a reference to this error. I have been looking for the error in developer forums, again with no luck finding it. I'm pretty sure it's a missing reference in Access, but I can not nail it down. I also seem to remember reading that Word 2010 does not use Frames any longer, but can't find that article again. I did notice that Text Boxes now have the Inside/Outside option.

    I have tried to record a macro in Word to get the code, but once I create the text box, the "Position" button is greyed out unless I stop recording, which defeats the purpose of recording.

    Does anyone have a solution to this?

    Monday, December 6, 2010 5:36 PM

Answers

  • You may want to consider posting this in the WORD FOR DEVELOPERS forum. Although you're working within Access, its Word that you're actually manipulating. There's also a very strong possibility that they may have some overall suggestions. For example, why are you creating a new MS Word document. Why not create a Word Template (.dot) and start with that?
    David H
    • Marked as answer by Bessie Zhao Tuesday, December 14, 2010 8:39 AM
    Monday, December 6, 2010 7:39 PM
  • Hi Bob

    Just happened to be skimming through this forum, today, but I agree with David's suggestion to take such questions to Word Developer:

    http://social.msdn.microsoft.com/Forums/en-US/worddev/threads

    FWIW Word finally implemented the new graphics engine that was introduced in Office 2007, which means the Drawing objects are no longer the same. That's why ConvertToFrame isn't working. And quite a number of things that should be in the object model aren't...

    Is there a reason you're creating these documents from-scratch, rather than using a template that contains standard things as the basis? That would be the simplest way to solve this, as the text box (or frame) could already be in the document with the appropriate formatting.

    The other possibility would be for you to distribute a template with your database that contains BuildingBlocks, such as a text box or frame with this formatting. These can be inserted as required, rather than being built from scratch.

    Another approach that could work would be to define a style that contains the Frame and apply that to the text in question.

    The only other thing that occurs to me would be to make sure this document is a *.doc (Word 2003 file format) or in the "Compatibility Mode" for Office 2007. Possibly, it will then generate the old type of text box and converttoframe will still work.

    Please note that I might not see any follow-up you post in this (Access) forum, so you may need to bring the discussion to Word Developer if you require more information (just copy a link to this thread so that you don't have to retype all the information).


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bessie Zhao Tuesday, December 14, 2010 8:39 AM
    Tuesday, December 7, 2010 10:27 AM
  • Thank you David and Cindy. I will post this in the Word Forum.

    btw: The reason I start the document from scratch is that I actually have multiple databases that I produce this document for and, depending on which database I am documenting, I place different text in the headers and footers (in the text boxes). The code resides in one database so I don't have to worry about changing redundant code. I change it once and it's fixed for all. I pass a variable to let it know which database to retrieve.

    I try to keep my questions simple so I can get simple answers. I've seen so many questions that ramble on about specifics and they are looking for specific answers so they don't have to think too much to fix the problem.

    Bob

    • Marked as answer by BobVezz Tuesday, December 14, 2010 2:07 PM
    Thursday, December 9, 2010 4:13 PM

All replies

  • You may want to consider posting this in the WORD FOR DEVELOPERS forum. Although you're working within Access, its Word that you're actually manipulating. There's also a very strong possibility that they may have some overall suggestions. For example, why are you creating a new MS Word document. Why not create a Word Template (.dot) and start with that?
    David H
    • Marked as answer by Bessie Zhao Tuesday, December 14, 2010 8:39 AM
    Monday, December 6, 2010 7:39 PM
  • Hi Bob

    Just happened to be skimming through this forum, today, but I agree with David's suggestion to take such questions to Word Developer:

    http://social.msdn.microsoft.com/Forums/en-US/worddev/threads

    FWIW Word finally implemented the new graphics engine that was introduced in Office 2007, which means the Drawing objects are no longer the same. That's why ConvertToFrame isn't working. And quite a number of things that should be in the object model aren't...

    Is there a reason you're creating these documents from-scratch, rather than using a template that contains standard things as the basis? That would be the simplest way to solve this, as the text box (or frame) could already be in the document with the appropriate formatting.

    The other possibility would be for you to distribute a template with your database that contains BuildingBlocks, such as a text box or frame with this formatting. These can be inserted as required, rather than being built from scratch.

    Another approach that could work would be to define a style that contains the Frame and apply that to the text in question.

    The only other thing that occurs to me would be to make sure this document is a *.doc (Word 2003 file format) or in the "Compatibility Mode" for Office 2007. Possibly, it will then generate the old type of text box and converttoframe will still work.

    Please note that I might not see any follow-up you post in this (Access) forum, so you may need to bring the discussion to Word Developer if you require more information (just copy a link to this thread so that you don't have to retype all the information).


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bessie Zhao Tuesday, December 14, 2010 8:39 AM
    Tuesday, December 7, 2010 10:27 AM
  • Thank you David and Cindy. I will post this in the Word Forum.

    btw: The reason I start the document from scratch is that I actually have multiple databases that I produce this document for and, depending on which database I am documenting, I place different text in the headers and footers (in the text boxes). The code resides in one database so I don't have to worry about changing redundant code. I change it once and it's fixed for all. I pass a variable to let it know which database to retrieve.

    I try to keep my questions simple so I can get simple answers. I've seen so many questions that ramble on about specifics and they are looking for specific answers so they don't have to think too much to fix the problem.

    Bob

    • Marked as answer by BobVezz Tuesday, December 14, 2010 2:07 PM
    Thursday, December 9, 2010 4:13 PM