I have a Word reporting system I built using VBA. I also have an Excel workbook that I have created using VBA which serves as a map, so that when the user clicks any cell, a message pops up with linked geographical data.
What I want to do is for when on the Word VBA userform, the user clicks into a particular textbox, the Excel workbook opens up- I know how to do that, but the next part I have no idea how to achieve:
When the user clicks a cell in the workbook,I want the data that appears in the message also populates the Word VA userform textbox. My problem is that the code that creates the message box with the geographical data is Excel code. How would I get that code to 'communicate with the Word document/ userform that opened it?
The code in Excel is as follows:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Select Case ActiveCell.Text
Case "B"
MsgBox "You selected part of the building on the picture" & vbCrLf & vbCrLf & "Map coordinates selected:" & vbCrLf & vbCrLf & "Easting: " & ActiveCell.Row & vbCrLf & "Northing: " & ActiveCell.Column
Case "L"
MsgBox "You selected part of lamp on the picture" & vbCrLf & vbCrLf & "Map coordinates selected:" & vbCrLf & vbCrLf & "Easting: " & ActiveCell.Row & vbCrLf & "Northing: " & ActiveCell.Column
Case ""
MsgBox "You selected part of the sky on the picture" & vbCrLf & vbCrLf & "Map coordinates selected:" & vbCrLf & vbCrLf & "Easting: " & ActiveCell.Row & vbCrLf & "Northing: " & ActiveCell.Column
Case "T"
MsgBox "You selected part of the tower on the picture" & vbCrLf & vbCrLf & "Map coordinates selected:" & vbCrLf & vbCrLf & "Easting: " & ActiveCell.Row & vbCrLf & "Northing: " & ActiveCell.Column
End Select
Exit Sub
MsgBox "You have selected an area with no picture"
End Sub