none
Using VBA - how to access the settings within in-built Word Dialog boxes?

    Question

  • Using VBA within MS Access to manipulate MS Word, I am trying to semi-automate a few of the aspects of two inbuilt Word dialog boxes.
     
    This first is the dialog box which is titled "Envelopes And Labels", and the second is accessed from within the first by clicking the the "Options..." button, this brings up the second dialog which is titled "Label Options".  The first dialog is accessed manually in Word by Mailings > Create > Labels.
     
    I have some of it sorted with many hours of google-based assistance; for instance the below code (extract) pre-sets the text in the dialog's "Address" field to a value on my access form, pre-sets the "Print" option to "Single label" (default is "Full page of the same label"), ensures that the tab displayed is the "Labels" tab, then displays the dialog (for the user to eventually manually input the row and column for the label to print on).
    	Set objWord = CreateObject("word.application")
    Set objDialogToolsEnvelopesAndLabels = objWord.dialogs(607) '(wdDialogToolsEnvelopesAndLabels) With objDialogToolsEnvelopesAndLabels .DefaultTab = 800001 'wdDialogToolsEnvelopesAndLabelsTabLabels .AddrText = Me.txtEnvelopeAddress .SingleLabel = 1
    .Show
    End With
    However I could really do with some pointers/assistance for the rest...
    In the secondary dialog ("Label Options") I want to pre-set the "Label Vendors" to (probably) "Avery A4/A5", then set the Product Number (I don't know to hand at this moment what it is, but it will be the same value every time).  I don't know what the names of these properties are, and I'm not even certain of the name/number of the dialog box (my current best guess is wdDialogToolsCreateLabels (489).
    Can someone please help me to set these values?  Better yet - is there a simple way to establish what these unknown dialog box names & property names are?
    Thanks in anticipation.
    This is my first post - I hope it is in the correct forum section.
    Windows 7; MS Word 2010; MS Access 2010 (& VBA)
    John.
    Tuesday, May 31, 2011 9:34 AM

Answers

  • Hi John,

    The developers reference is a great resource, I keep it bookmarked and even multiple sections set as favorites. Sometimes, I think it's information could be a little better cross referenced but on a whole, again it's invaluable.

    Glad it all worked out.


    Kind Regards, Rich ... http://greatcirclelearning.com
    Tuesday, May 31, 2011 3:41 PM
  • <<however the web page posted by Rich Michaels has put the icing on the cake>>

    Yes, that's the same as the Word VBA Help file information to which I referred in my previous message.

    The problem with this information, however, is that it doesn't supply you with any information about the expected data types for the arguments, which in some cases is critical. For that, you need the old WordBasic information...


    Cindy Meister, VSTO/Word MVP
    Tuesday, May 31, 2011 6:12 PM
    Moderator

All replies

  • Hi John

    Not all fields in all dialog boxes can be accessed. This is a carry-over from the WordBasic days (Word 95 and earlier) and hasn't been fully supported since the transition to VBA. So there may be some things (especially newer things) that you can't affect, with the possible exception of SendKeys.

    That said, your first resource is to look in Word's VBA Help for "Built-in dialog box arguments". That will let you get to a list of all dialog boxes and the fields that should be exposed (some are listed that no longer work and there are some that aren't in the list that do work - bit of a lottery).

    What's not documented here is the accepted value types. The only (limited) resource for this is the old Word Developers Kit - essentially, the Word 6/95 WordBasic Help. The dialog box fields correspond to arguments of the old WordBasic methods and functions, for the commands old enough to have been in existence at the time. I think you can d/l this information at word.mvps.org.


    Cindy Meister, VSTO/Word MVP
    Tuesday, May 31, 2011 10:04 AM
    Moderator
  • Hi John,

    Maybe this will help.

    http://msdn.microsoft.com/en-us/library/ff845471.aspx


    Kind Regards, Rich ... http://greatcirclelearning.com
    Tuesday, May 31, 2011 10:42 AM
  • Cindy thank you very much for your reply.

    My previous search efforts had turned up (it may well have been from your reply to someone else in some forum also seeking assistance with accessing Word's inbuilt dialog boxes using VBA) that I should look for the WordBasic help, however that proved quite difficult as my Windows 7 (64 bit) machine can't inherently open that file, and the fix (WinHlp32.exe) to allegedly allow me to open it failed to install on my machine for reasons unknown to me. I eventually got to open the WordBasic help file on an old WINXP laptop, however the web page posted by Rich Michaels has put the icing on the cake.

    Tuesday, May 31, 2011 3:17 PM
  • Rich, thank you so very much; I wish my prior google efforts had turned up that page - it is exactly what I need! Why is it so hard to come by? Thank you, and thank you again!
    Tuesday, May 31, 2011 3:19 PM
  • Hi John,

    The developers reference is a great resource, I keep it bookmarked and even multiple sections set as favorites. Sometimes, I think it's information could be a little better cross referenced but on a whole, again it's invaluable.

    Glad it all worked out.


    Kind Regards, Rich ... http://greatcirclelearning.com
    Tuesday, May 31, 2011 3:41 PM
  • <<however the web page posted by Rich Michaels has put the icing on the cake>>

    Yes, that's the same as the Word VBA Help file information to which I referred in my previous message.

    The problem with this information, however, is that it doesn't supply you with any information about the expected data types for the arguments, which in some cases is critical. For that, you need the old WordBasic information...


    Cindy Meister, VSTO/Word MVP
    Tuesday, May 31, 2011 6:12 PM
    Moderator