james4189
09-06-2015, 10:32 PM
I have a document that contains a Rich Text Content Control. I show a form when it is clicked with:
Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)
If ContentControl.Title = "MaxPointsA" Then
frmMaxPoints.Show
frmMaxPoints.txtboxMaxPoints.SetFocus
End If
End Sub
When the user clicks the cancel button on the form, it hides it with:
' this extra sub for hiding was just so I could place all of my testing code in one place
' while I was trying to get it to work.
Private Sub HideForm()
frmMaxPoints.Hide
End Sub
Private Sub btnCancel_Click()
Call HideForm
End Sub
What I want is to be able to have the form hidden & be able to immediately click the content control again & have it reshow the form (strictly for oops I made a mistake & need to change it moments). As it stands I have to click out of the content control, somewhere else on the document, and then click the content control to get it to appear.
I search a lot for an answer and have tried what little I found with no luck.
I've tried these, suggestions I found, after hiding the form:
' This Did nothing
Word.Application.Activate
' This Moved the cursor, but the word window did not have focus so I still had to click twice.
' Once to set focus to the word app and again to click the content control.
Selection.MoveDown
' This allowed the word app to regain focus after the form was hidden,
' but I still had to click out of the content control & back in.
' setting ShowModal to false
These two together made it work, but only when I click the cancel button & just hide the form.
' setting ShowModal to false
Selection.MoveDown
If the user clicks accept it runs
Private Sub btnAccept_Click()
SetPointScales txtboxMaxPoints
Call HideForm
End Sub
SetPointScales loops through a table (about 40 rows) and places a number in the first cell & a date in the second.
Clicking accept the cursor does move out of the content control, but the word app does not regain focus after the form hides so I still have to click the content control twice. Once for word to regain focus & again to click the content control.
Any ideas what I'm doing wrong?
Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)
If ContentControl.Title = "MaxPointsA" Then
frmMaxPoints.Show
frmMaxPoints.txtboxMaxPoints.SetFocus
End If
End Sub
When the user clicks the cancel button on the form, it hides it with:
' this extra sub for hiding was just so I could place all of my testing code in one place
' while I was trying to get it to work.
Private Sub HideForm()
frmMaxPoints.Hide
End Sub
Private Sub btnCancel_Click()
Call HideForm
End Sub
What I want is to be able to have the form hidden & be able to immediately click the content control again & have it reshow the form (strictly for oops I made a mistake & need to change it moments). As it stands I have to click out of the content control, somewhere else on the document, and then click the content control to get it to appear.
I search a lot for an answer and have tried what little I found with no luck.
I've tried these, suggestions I found, after hiding the form:
' This Did nothing
Word.Application.Activate
' This Moved the cursor, but the word window did not have focus so I still had to click twice.
' Once to set focus to the word app and again to click the content control.
Selection.MoveDown
' This allowed the word app to regain focus after the form was hidden,
' but I still had to click out of the content control & back in.
' setting ShowModal to false
These two together made it work, but only when I click the cancel button & just hide the form.
' setting ShowModal to false
Selection.MoveDown
If the user clicks accept it runs
Private Sub btnAccept_Click()
SetPointScales txtboxMaxPoints
Call HideForm
End Sub
SetPointScales loops through a table (about 40 rows) and places a number in the first cell & a date in the second.
Clicking accept the cursor does move out of the content control, but the word app does not regain focus after the form hides so I still have to click the content control twice. Once for word to regain focus & again to click the content control.
Any ideas what I'm doing wrong?