I had a idea to make a macro that on a hot key press (Ctrl+shift+arrow key) brings up a minimalist form where you can just enter a precise amount for a nudge and press enter to execute... nothing difficult in getting the functionality working but it did bring up two problems I've yet been unable to figure out:
1: Is it possible to position the window relative to your active selection range if its in the screen space (without changing the window position)?
2: Can you make a form so its just the textbox only? I've figured out how to remove the windows boarder and how to make the whole thing transparent but what I would just like to set the background to transparent and leave the textbox opaque.
This is not at all critical but it would certainly make it more presentable! Would be quite useful for others to use to
Example of form in Current state:
Form Code:
Option Explicit Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long Private Declare PtrSafe Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long Private Const GWL_EXSTYLE = (-20) Private Const WS_EX_LAYERED = &H80000 Private Const LWA_ALPHA = &H2& Public hWnd As Long Sub RemoveTitleBar(frm As Object) Dim lStyle As Long Dim hMenu As Long Dim bytOpacity As Byte bytOpacity = 111 ' variable keeping opacity setting hWnd = FindWindow("ThunderDFrame", frm.Caption) lStyle = GetWindowLong(hWnd, -16) lStyle = lStyle And Not &HC00000 SetWindowLong hWnd, -16, lStyle DrawMenuBar hWnd Call SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED) Call SetLayeredWindowAttributes(hWnd, 0, bytOpacity, LWA_ALPHA) End Sub Sub XNudge() ActiveDocument.Unit = cdrMillimeter NudgeUF.Show False End Sub
Module Code:
Option Explicit Private Sr As ShapeRange Private LeftND As Double Private Sub NudeTB_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 13 Then If Not ActiveSelectionRange Is Nothing Then Set Sr = ActiveSelectionRange LeftND = Val(NudeTB.Value) If LeftND < 0 Then Sr.Move LeftND, 0 ElseIf LeftND > 0 Then Sr.Move LeftND * -1, 0 End If Unload Me End If End If End Sub Private Sub UserForm_Activate() With NudgeUF .Top = 150 .Left = 225 End With End Sub Private Sub UserForm_Initialize() Call RemoveTitleBar(Me) End Sub