I found this topic, but what I need is more specific.
community.coreldraw.com/.../290975
I just want a pop up box warning the user when the doc is saved that there are dynamic dimensions on certain pages and how many.
You could try this:
Sub Count_Dynamic_Dims_Doc() Dim pageThis As Page Dim lngDynamicCountThisPage As Long Dim lngDynamicCountTotal As Long If Not ActiveDocument Is Nothing Then For Each pageThis In ActiveDocument.Pages lngDynamicCountThisPage = pageThis.Shapes.FindShapes(, cdrLinearDimensionShape, , "@com.dimension.dynamictext='True'").Count Select Case lngDynamicCountThisPage Case 0 'Do nothing Case 1 MsgBox "Page " & pageThis.Index & " has " & "1 dynamic dimension." Case Else MsgBox "Page " & pageThis.Index & " has " & lngDynamicCountThisPage & " dynamic dimensions." End Select lngDynamicCountTotal = lngDynamicCountTotal + lngDynamicCountThisPage Next pageThis Select Case lngDynamicCountTotal Case 0 MsgBox "Done." & vbCrLf & vbCrLf & "No dynamic dimension were found in the document." Case 1 MsgBox "Done." & vbCrLf & "1 dynamic dimension was found in the document." Case Else MsgBox "Done." & vbCrLf & vbCrLf & lngDynamicCountTotal & " dynamic dimensions were found in the document." End Select Else MsgBox "No document is active." End If End Sub
Cool. Now if I need another purpose for this - I could strip away the unneeded bits and configure it to check the doc upon saving which will alert the user that there is a dynamic dimension(s) on a page. That would terrific!
This does the same checks as the first code I showed, but collects the information in a single string to be shown in the message box:
Sub Dynamic_Dims_Report_Doc(Optional NoMessageIfNegative As Boolean) Dim pageThis As Page Dim lngDynamicCountThisPage As Long Dim lngDynamicCountTotal As Long Dim strMessage As String If Not ActiveDocument Is Nothing Then strMessage = "Dynamic Dimensions Report:" & vbCrLf For Each pageThis In ActiveDocument.Pages lngDynamicCountThisPage = pageThis.Shapes.FindShapes(, cdrLinearDimensionShape, , "@com.dimension.dynamictext='True'").Count Select Case lngDynamicCountThisPage Case 0 'Do nothing Case 1 strMessage = strMessage & vbCrLf & "Page " & pageThis.Index & " has " & "1 dynamic dimension." Case Else strMessage = strMessage & vbCrLf & "Page " & pageThis.Index & " has " & lngDynamicCountThisPage & " dynamic dimensions." End Select lngDynamicCountTotal = lngDynamicCountTotal + lngDynamicCountThisPage Next pageThis Select Case lngDynamicCountTotal Case 0 strMessage = strMessage & vbCrLf & "No dynamic dimensions were found in the document." Case 1 strMessage = strMessage & vbCrLf & vbCrLf & "1 dynamic dimension was found in the document." Case Else strMessage = strMessage & vbCrLf & vbCrLf & lngDynamicCountTotal & " dynamic dimensions were found in the document." End Select If Not (NoMessageIfNegative And lngDynamicCountThisPage = 0) Then MsgBox strMessage, vbInformation, "Dynamic Dimensions Report" End If Else MsgBox "No document is active.", vbInformation, "Dynamic Dimensions Report" End If End Sub
Since you want to run this automatically, I've provided the option to NOT have it show the message box if no dynamic dimensions were found.
You could run this using something in the ThisMacroStorage section of the project. This, for example, would run it on the DocumentBeforeSave event:
Private Sub GlobalMacroStorage_DocumentBeforeSave(ByVal Doc As Document, ByVal SaveAs As Boolean, ByVal FileName As String) Dynamic_Dims_Report_Doc True End Sub
If you omit the "True" there, then it shows the message box even if no dynamic dimensions were found.
You're truly amazing John. I really appreciate your help.
Cheers!