• How to show File/Properties dialog box? (Office XP, Word 2002)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » How to show File/Properties dialog box? (Office XP, Word 2002)

    Author
    Topic
    #383906

    Can someone guide me to how to write VBA code to open the File/Properties dialog box.

    I can only find the argument wdDialogFileSummaryInfo.

    I have tried code: Dialogs(wdDialogFileSummaryInfo).Show

    But this dialog box does not contain the text box for Category.

    Thanks in advance!

    Bjorn

    Viewing 1 reply thread
    Author
    Replies
    • #656487

      I don’t know if this will be of any help, but from the Word 2000 VBA Help file under the topic “Storing values when a macro ends”:

      To access built-in properties, use the BuiltInDocumentProperties property to return a DocumentProperties collection that includes the built-in document properties. Use the CustomDocumentProperties property to return a DocumentProperties collection that includes the custom document properties. The following example creates a custom document property named “YourName” in the same location as the macro that is running (document or template).

      ThisDocument.CustomDocumentProperties.Add Name:=”YourName”, _
      LinkToContent:=False, Value:=”Joe”, Type:=msoPropertyTypeString
      Built-in document properties cannot be added to the DocumentProperties collection returned by the BuiltInDocumentProperties property. You can, however, retrieve the contents of a built-in document property or change the value of a read/write built-in document property.

      Note You can use the DOCPROPERTY field to insert document properties into a document.

      Alan

    • #656499

      hi Bjorn,

      Application.Run MacroName:=”FileProperties”

      is the only possible way i believe.

      greetings,

      • #656558

        Or you need to use the constant 750 for the Dialog, which MS forgot in the list of wdDialog constants:

          Application.EnableCancelKey = wdCancelDisabled
          Dialogs(750).Show
          Application.EnableCancelKey = wdCancelInterrupt

        cheers Klaus

        • #656566

          hi Klaus,

          aha now that’s interesting! do you have by any chance a complete listing of dialogs for which there is not a corresponding dialog constant.
          for instance
          – the edit find dialog, but with all tabs enabled?
          – the add watermark dialog (format->background->printed watermark…)
          – ….

          i’m running the numbers right now but they haven’t come up yet.

          greetings,

          • #656622

            Do you just need a way to programmatically open the dialogs?

            Edit | Find:

            commandbars.FindControl(ID:=141).Execute

            WaterMark:

            commandbars.FindControl(ID:=4003).Execute

          • #656720

            Hi Pieter,

            > – the edit find dialog, but with all tabs enabled?
            > – the add watermark dialog (format->background->printed watermark…)

            I would use Kevin’s method. Some dialogs simply don’t work as you would expect, but the commandbar controls seem to always work fine.

            Probably CommandBars.FindControl(ID:=someID).Execute really does exactly the same as choosing the corresponding toolbar button or menu item.

            cheers Klaus

            • #656722

              thanks Kevin and Klaus,

              somehow i was temporarily unaware of the findcontrole().execute statement. your posts proved an excellent reminder!

              greetings,

          • #657000

            I thought it should be possible to compile a list using something like this:

            Sub DlgFinder()
            Dim dlg As Dialog, intCounter As Integer
            With ActiveDocument.Content
                For intCounter = 1 To 100
                    On Error Resume Next
                    Set dlg = Dialogs(intCounter)
                    If Err.Number  0 Then
                        .InsertAfter intCounter & vbTab & "Error #" & _
                            Err.Number & " (" & Err.Description & _
                            ")" & vbCrLf
                        Err.Clear
                    Else
                        dlg.Display 2000 ' Show dialog for 2 seconds
                        .InsertAfter intCounter & vbTab & InputBox("Name that dialog") & vbCrLf
                    End If
                Next
            End With
            Set dlg = Nothing
            End Sub

            But most of the “dialogs” are completely invisible, or offer only scant clues as to what they do (such as “Copy From Where” on the status bar or the sudden appearance of a pair of field braces in the document). When the Help window pops up, I don’t know which of the various Help commands they are. I used Ctrl+Break to stop when I couldn’t stand it any more, and I noticed that Overtype was toggled. Very weird. So, I gave up for now, but someday….

            Regarding the ones that are in the dialogs collection “officially,” see the attached (it’s old, but I have no reason to think this has changed).

        • #656595

          In W2K it is not even in the Dialogs collection.

          This is what I did:

          Dim dlg As Dialog

          For Each dlg In Dialogs
          If dlg.Type = 750 Then
          Stop
          End If
          Next

          and it didn’t stop.

          However if I use what you posted Dialogs(750).Show, then there it is.

          And I second pieters request, do you have a complete list?

          • #656598

            hi Bryan,

            that seems logical. the dialog collection only contains thos dialogs for which there’s a dialogconstant.
            in the mean time i’m running a loop which displays all dialogs and crashed word several times already in the process.
            it has come up with the strangest things (launching office application, help, showing tooltips, displaying a splash screen for MS schedule+ (!)), but the dialognumbers for the dialogs mentioned in previous mail remain elusive… blackhole

            greetings

            • #656599

              Actually to me it doesn’t seem logical that it isn’t in the Dialogs collection.

              The wdDialog constants are just that, constants.

              But when you use Dialogs(750).Show to display the FileProperties Dialog you are accessing a Dialog with the Index # of 750 in the Dialogs collection.

              It just doesn’t make sense to me.

              Oh wait, it’s just another MSism that we have come to know, love and work around grin

            • #656721

              > it has come up with the strangest things

              Hi Pieter,

              Yes, there seems to be a dialog constant for just about every command.

              Some things you can try:
              Select some text, then
              Dialogs(46).Show
              will make it italic.
              Dialogs(248).Show
              will apply the “Normal” style.

              I have a long list with such stuff, but since you can do all these things in other more transparent ways, it’s more of a curiosity.

              cheers Klaus

        • #656706

          Thanks a lot It works!

          Like that it was encountered for the Cancel key.

          Bjorn

      • #656707

        Thanks Pieter, it works!

        I also tried what Klaus Linke posted. This is also working.

        I’m not an experienced VBA coder so, Q:

        What would be the code for disabling the Cancel key when “Application.Run MacroName:=”FileProperties”” are used?

        Bjorn

        • #656724

          Hi Bjorn,

          > What would be the code for disabling the Cancel key when “Application.Run MacroName:=”FileProperties”” are used?

          You could use Application.EnableCancelKey the same way.
          Many times you’ll see “On error resume next” when dialogs are displayed, but I think disabling the Esc key is neater.

          cheers Klaus

          • #657059

            Hi Klaus,

            It works Ok, but when the dialog box closes the document is no longer the acitve document. I have tried several ways of making the document active (shown on the screen) again, after the dialog box closes but haven’t found a way.
            The code is arranged such that when dobbeklikking or opening the Header/Footer, the File/Properties dialog box opens.

            I have an EventClassModule where the following code is stored:

            Option Explicit

            Public WithEvents App As Word.Application

            Private Sub App_WindowBeforeDoubleClick(ByVal Sel As Selection, Cancel As Boolean)
            ThisDocument.SpellingFlagg = True
            End Sub

            Private Sub App_WindowSelectionChange(ByVal Sel As Selection)

            If ThisDocument.SpellingFlagg = True Then
            ‘On Error Resume Next
            ‘quit if active doc isn’t attached to this template
            If ActiveDocument.AttachedTemplate = ThisDocument Then Exit Sub
            ‘get out of the header/footer if we’re in it
            If Sel.StoryType = wdEvenPagesFooterStory Or _
            Sel.StoryType = wdEvenPagesHeaderStory Or _
            Sel.StoryType = wdFirstPageFooterStory Or _
            Sel.StoryType = wdFirstPageHeaderStory Or _
            Sel.StoryType = wdPrimaryFooterStory Or _
            Sel.StoryType = wdPrimaryHeaderStory Then
            ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

            If ActiveDocument.Name = “Document in Microsoft Internet Explorer” Then
            MsgBox “You should click ‘SaveAs’ to edit document”
            Exit Sub
            End If

            If ActiveDocument.ReadOnly = True Then
            MsgBox “You should check out the document before editing”
            Exit Sub
            End If

            ThisDocument.SpellingFlagg = False

            Application.EnableCancelKey = wdCancelDisabled
            Application.Run MacroName:=”FileProperties”
            ‘Dialogs(750).Show
            Application.EnableCancelKey = wdCancelInterrupt
            Exit Sub
            End If
            End If
            ThisDocument.SpellingFlagg = False
            End Sub

            In ThisDocument I have the following code to work with the event module:

            Option Explicit
            Dim strDocId As String, Response As Variant
            Dim NewDoc As String
            Private ProtectHandler As New EventClassModule

            Public SpellingFlagg As Boolean
            Public ShowDateAndHour As String

            Public Sub Register_Event_Handler()
            Set ProtectHandler.App = Word.Application
            End Sub

            Private Sub Document_Open()
            Register_Event_Handler
            End Sub

            Sub Document_Close()
            If ActiveDocument.ReadOnly = True Then
            Set ProtectHandler.App = Nothing
            Set ProtectHandler = Nothing
            Exit Sub
            End If
            Set ProtectHandler.App = Nothing
            Set ProtectHandler = Nothing
            End Sub

            Can you suggest any way to make the document active again?

            Thanks!!!

            Regards
            Bjorn

            • #657072

              Hi Bjorn,

              One simple (and inelegant) way to make the document active again would be to show a message box.

              If I have a bit more time, I’ll look at your code and try to figure out something better … perhaps .Activate works?

              cheers Klaus

            • #658385

              Bjorn, Klaus:

              Forgive me if this was already suggested in this thread, but the following:

              WordBasic.FileProperties ‘*

              will also show the File Properties dialog. Does this method make any difference with the focus problem?

              Gary

              * From article at MS MVPs site: here.

            • #658416

              Hi,

              Thanks for the interest and help!!

              I have tried the last WordBasic.FileProperties, but it behaves in the same way.

              I have changed my coding to the following, which solve my problem for the time being:

              With ThisDocument.CommandBars(“FileProperties”)
              .Controls(“File Properties Summary”).Execute
              End With

              I have created a Toolbar called “FileProperties” and then inserted the control, the button Properties from Customize/File, which I call “File Properties Summary”
              Doing so it work properly. But I’m sure there is another way of doing it without having to create a special Toolbar. It is quite sure that I must create a code that get hold of the actual window number. Probably I have to first count the total number of windows and then select the one I want to activate. I will try this soon.

              Thanks for good help!

              Regards
              Bjorn

    Viewing 1 reply thread
    Reply To: How to show File/Properties dialog box? (Office XP, Word 2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: