Message box display

julhs

Active Member
Joined
Dec 3, 2018
Messages
471
Office Version
  1. 2010
Platform
  1. Windows
I’ve been playing around with adapting the 2 shape routines below to return results as one;
With this from Norie
VBA Shape Node Points x position
and "DetermineShapeType" from "The SpreadsheetGuru";
VBA Coding For Shapes (The Complete Guide)

My code code todate is this.
VBA Code:
Option Explicit
'     Combining "Determine Shape Type" with "Get Points"
Sub MeDetermineShapeTypeGetPoints()
Dim sh As Variant
Dim nd As Variant
Dim xy As Variant
Dim nodemsg As String
Dim I As Variant

Dim ActiveShape As Shape
Dim UserSelection As Variant

'Pull-in what is selected on screen
  Set UserSelection = ActiveWindow.Selection

'Determine if selection is a shape
  On Error GoTo NoShapeSelected
    Set ActiveShape = ActiveSheet.Shapes(UserSelection.Name)
  On Error Resume Next
  
   Set sh = ActiveShape 'ActiveWindow.Selection
    For Each nd In sh.Nodes
        xy = nd.Points
        I = I + 1
        nodemsg = nodemsg & "The Select Shape Type = " & ActiveShape.AutoShapeType & vbLf & "Node " & I & ": x =" & xy(1, 1) & " y=" & xy(1, 2) & vbCrLf      
    Next
        MsgBox nodemsg    
 'Error Handler
NoShapeSelected:
  MsgBox "You do not have a shape selected!"    
End Sub

My trouble is I can’t fathom out how to display the 2 results in the message box in the way I want them to appear.
This is the result of my code above at combining them todate.

1696106793226.png

BUT I want Msg box to display as,
Rich (BB code):
The Selected Shape Type = 138
Node 1:x=205.2y=879.2
Node2 ........
Node3.........
etc
Note; when code is run it does default to the error handler at the end of the routine, which I need to address in some way
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
My trouble is I can’t fathom out how to display the 2 results in the message box in the way I want them to appear.
You need to separate the output.

Try following:
VBA Code:
nodemsg = nodemsg & "Node " & I & ": x =" & xy(1, 1) & " y=" & xy(1, 2) & vbCrLf
Next
MsgBox "The Select Shape Type = " & ActiveShape.AutoShapeType & vbLf & nodemsg
 
Upvote 0
Thanks for response Peter
Worked as I wanted.
BUT have would I add a blank line/space between "The Select Shape Type" and the "Node1......"

Rich (BB code):
The Selected Shape Type = 138

Node 1:x=205.2y=879.2
Node2 ........
Node3.........
etc
 
Upvote 0
Ok figured it out.
VBA Code:
nodemsg = nodemsg & "Node " & I & ": x =" & xy(1, 1) & " y=" & xy(1, 2) & vbCrLf
Next
MsgBox "The Select Shape Type = " & ActiveShape.AutoShapeType & vbCrLf & vbCrLf & nodemsg
 
Upvote 0
here it is:
VBA Code:
nodemsg = nodemsg & "Node " & I & ": x =" & xy(1, 1) & " y=" & xy(1, 2) & vbCrLf
Next
MsgBox "The Select Shape Type = " & ActiveShape.AutoShapeType & vbLf & vbLf & nodemsg
 
Upvote 0
Solution
Interested to know why you are using
Rich (BB code):
vbLf and not vbCrLf
 
Upvote 0
Uh, must be a mistake, didn't notice that.
Should be vbCrLf instead
 
Upvote 0
Didn't realy make any difference as vbLf worked just as well.
Many thanks for your help
Julhs
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,206
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top