DoCmd error with FileSummary Info Dialog

D

Dan

I am using Visual Basic 6 to automate Visio 2002 on a
Windows XP machine. In a class module, I have code to open
the SaveAs Dialog window followed by the FileSummaryInfo
dialog.

Visio raises error -2032466955 when the user clicks the
Cancel button on the File Properties dialog. Visio also
raises the same error when the user clicks OK without
entering any information in the form fields (subject,
author, company...).

This macro code shows how to reproduce the issue with the
FileSummaryInfo dialog.
- Open a drawing using the Basic Diagram Visio Template.
- Open the VBA Editor (alt-f11)
- Copy and paste the code in the ThisTemplate VBA module:

Private Sub Document_ShapeAdded(ByVal Shape As IVShape)

On Error GoTo SAVE_AS_HANDLER
' show Visio Save As dialog box
Application.DoCmd visCmdFileSaveAs ' OK, no problem!

On Error GoTo FILE_INFO_SUMMARY_HANDLER

' Visio raises error -2032466955 when user clicks 'Cancel'
on the File Property Dialog
' Visio also raises the error when user clicks OK without
entering any data in the File Property Dialog
' show Visio File Properties dialog box: title, author,
description...
Application.DoCmd (visCmdFileSummaryInfoDlg)

Exit Sub
SAVE_AS_HANDLER:
Debug.Print "SaveAs error: '" & Err.Number & "' " &
Err.Description
FILE_INFO_SUMMARY_HANDLER:
Debug.Print "FileSummaryInfoDlg error: '" & Err.Number
& "' " & Err.Description
End Sub

- Drop a shape on the drawing.
- In the immediate window of the VBA editor you will see:

FileSummaryInfoDlg error: '-2032466955' Cancel.

I've tried this with and without the 'Prompt for document
properties" option setting.(Tools->Options->Save tab).

What's wrong with the above code?

I've submitted this to the Microsoft online support but
was not provided with a fix or a workaround like they did
in the past for an issue with the accelerator menu.

Thanks
 
J

Jon Summers

Dan ...
Visio raises error -2032466955 when the user clicks the
Cancel button on the File Properties dialog.

It's a peculiarity of the Microsoft Common Dialog as implement in VB.
Just write your code to catch the error. Here's an example from MSDN:

Private Sub mnuFileOpen_Click ()
' CancelError is True.
On Error GoTo ErrHandler
' Set filters.
CommonDialog1.Filter = "All Files (*.*)|*.*|Text _
Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
' Specify default filter.
CommonDialog1.FilterIndex = 2

' Display the Open dialog box.
CommonDialog1.ShowOpen
' Call the open file procedure.
OpenFile (CommonDialog1.FileName)
Exit Sub

ErrHandler:
' User pressed Cancel button.
Exit Sub
End Sub
 
D

Dans

Thanks for your reply Jon.

I've tried catching the error or using resume next but the problem is
that VB also raises the error when the user clicks OK without entering
any data on the form fields (subject, author, company...).

I'd like to know which button was clicked and by trapping the error
there is no way to distinguish 'User pressed Cancel button' from
'User was lazy and pressed OK without filling any of the form fields'.

Not sure if this is a peculiarity of the File Properties Dialog or just
the way Visio process the click event.

I've tested similar code with a MS Word VBA macro and no error is raised
by the Cancel or OK buttons.

Private Sub WordDoc_DocumentChange()
Dim dlgSave As Dialog
Dim dlgInfo As Dialog

On Error GoTo SAVE_AS_HANDLER
Set dlgSave = WordDoc.Dialogs(wdDialogFileSaveAs)
dlgSave.Show

On Error GoTo FILE_INFO_SUMMARY_HANDLER
Set dlgInfo = WordDoc.Dialogs(wdDialogFileSummaryInfo)
dlgInfo.Show
Exit Sub
SAVE_AS_HANDLER:
Debug.Print "SaveAs error: '" & Err.Number & "' " & Err.Description
FILE_INFO_SUMMARY_HANDLER:
Debug.Print "FileSummaryInfoDlg error: '" & Err.Number & "' " &
Err.Description

End Sub


Thanks

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top