- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
让我以我是自学成才的事实作为我的问题的开头,所以请提供尽可能详细的信息,如果我需要您以不同的方式或多次解释,请耐心等待。
我使用 Microsoft Visual Basic 7.0 为我的团队创建了一个符号/电子邮件生成工具。我收到的唯一提示是他们中的许多人不习惯热键,所以他们依赖于使用鼠标,但右键单击不起作用。当他们使用右键单击时,我能够找到创建用于复制和粘贴的弹出窗口的代码,并且它在主窗体本身的几个文本框上工作得很好,但是它不适用于大多数文本框,因为他们在多页中。
有谁知道如何修改下面的代码以适用于多页上的文本框?此外,在提出建议之前,我确实考虑过将所有内容移出多页的想法,但是这种格式是最简单的,因为他们需要随时发送多个阶段和类型的笔记/电子邮件,所以有他们只需单击即可使用的选项卡是我能够创建的最用户友好的,并且他们都同意。
提前谢谢大家!
表单中的代码:
Dim cBar As clsBar
Private Sub UserForm_Initialize()
On Error GoTo Whoa
Application.EnableEvents = False
Set cBar = New clsBar
cBar.Initialize Me
Letscontinue:
Application.EnableEvents = True
Thoát Sub
Whoa:
MsgBox Err.Description
Resume Letscontinue
End Sub
类模块中的代码:
Option Explicit
'Popup objects
Private cmdBar As CommandBar
Private WithEvents cmdCopyButton As CommandBarButton
Private WithEvents cmdPasteButton As CommandBarButton
'Useform to use
Private fmUserform As Object
'Control array of textbox
Private colControls As Collection
'Textbox Control
Private WithEvents tbControl As MSForms.TextBox
'Adds all the textbox in the userform to use the popup bar
Sub Initialize(ByVal UF As Object)
Dim Ctl As MSForms.Control
Dim cBar As clsBar
For Each Ctl In UF.Controls
If TypeName(Ctl) = "TextBox" Then
'Check if we have initialized the control array
If colControls Is Nothing Then
Set colControls = New Collection
Set fmUserform = UF
'Create the popup
CreateBar
End If
'Create a new instance of this class for each textbox
Set cBar = New clsBar
cBar.AssignControl Ctl, cmdBar
'Add it to the control array
colControls.Add cBar
End If
Next Ctl
End Sub
Private Sub Class_Terminate()
'Delete the commandbar when the class is destroyed
Trên Lỗi Tiếp Tục Tiếp Theo
cmdBar.Delete
End Sub
'Click event of the copy button
Private Sub cmdCopyButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
fmUserform.ActiveControl.Copy
CancelDefault = True
End Sub
'Click event of the paste button
Private Sub cmdPasteButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
fmUserform.ActiveControl.Paste
CancelDefault = True
End Sub
'Right click event of each textbox
Private Sub tbControl_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 And Shift = 0 Then
'Display the popup
cmdBar.ShowPopup
End If
End Sub
Private Sub CreateBar()
Set cmdBar = Application.CommandBars.Add(, msoBarPopup, False, True)
'We’ll use the builtin Copy and Paste controls
Set cmdCopyButton = cmdBar.Controls.Add(ID:=19)
Set cmdPasteButton = cmdBar.Controls.Add(ID:=22)
End Sub
'Assigns the Textbox and the CommandBar to this instance of the class
Sub AssignControl(TB As MSForms.TextBox, Bar As CommandBar)
Set tbControl = TB
Set cmdBar = Bar
End Sub
1 Câu trả lời
获取多页控件上的 ActiveControl 名称
有必要通过辅助函数 (ActiveControlName) 使用 SelectedItem
属性并从那里获取控件(它的名称)来了解多页的选定 Page
。按如下方式更改您的按钮点击事件:
类模块clsBar中的相关按钮点击事件
'Click event of the copy button
Private Sub cmdCopyButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
Dim sACN As String
sACN = ActiveControlName(fmUserform) ' find control's name
' Debug.Print sACN & ".Copy"
fmUserform.Controls(sACN).Copy ' << instead of fmUserform.ActiveControl.Copy
CancelDefault = True
End Sub
'Click event of the paste button
Private Sub cmdPasteButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
Dim sACN As String
sACN = ActiveControlName(fmUserform)
' Debug.Print sACN & ".Paste"
fmUserform.Controls(sACN).Paste ' << instead of fmUserform.ActiveControl.Paste
CancelDefault = True
End Sub
上面点击事件调用的辅助函数
Function ActiveControlName(form As UserForm) As String
'cf Site: https://stackoverflow.com/questions/47745663/get-activecontrol-inside-multipage
'Purpose: get ActiveControl
Dim MyMultiPage As MSForms.MultiPage, myPage As MSForms.Page
If form.ActiveControl Is Nothing Then
' do nothing
ElseIf TypeName(form.ActiveControl) = "MultiPage" Then
Set MyMultiPage = form.ActiveControl
Set myPage = MyMultiPage.SelectedItem
ActiveControlName = myPage.ActiveControl.Name
Else
ActiveControlName = form.ActiveControl.Name
End If
End Function
旁注
建议在空字符串的情况下检查所选文本字符串的长度,以防止出现不需要的结果。
关于excel - VB在多页中右键单击复制/粘贴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51212288/
Tôi đang viết một ứng dụng cho phép người dùng tạo "bảng câu hỏi" và sau đó thêm câu hỏi vào đó. Tôi đang sử dụng dữ liệu cốt lõi để lưu trữ thông tin. Tôi đã tạo một thực thể Hỏi đáp và thiết lập mối quan hệ Một-nhiều với thực thể Câu hỏi. Câu hỏi của tôi là, nếu tôi muốn cho phép người dùng sao chép (sao chép) toàn bộ
Có cách nào để sao chép hoặc nhân đôi SharedPreference không? Hay tôi cần lấy từng biến từ một biến rồi đưa chúng vào một biến khác? Câu trả lời hay nhất Hãy thử một cái gì đó như thế này: //sp1 là tùy chọn được chia sẻ
Có sự khác biệt nào giữa (A) và (B) dưới đây không? (giả sử KHÔNG phải ARC, nếu điều đó quan trọng) // --- (A) --- @interface Zoo : NSObject{} @property (sao chép) Dog
Tôi đang cố lưu truy vấn mysql SELECT vào một tệp như thế này: $result = mysqli_query($db,$sql); $out = fopen('tmp/csv.csv', 'w'
Tôi cần tạo một bản sao của CVPixelBufferRef để có thể sử dụng các giá trị trong bản sao để thao tác bộ đệm pixel gốc theo từng bit. Có vẻ như tôi không thể sử dụng CVPixelBufferCreate hoặc CVPixelBufferCr
Tôi có tệp ghi âm sóng hoạt động wave-file.wav trong thư mục Nguồn. Tôi cần sao chép tệp này vào thư mục Đích với tên mới là wave-file-copy.wav.
Trong một dự án được xây dựng bằng GNU Autotools, tôi có một tập lệnh cần sửa đổi thông qua lệnh make để bao gồm đường dẫn cài đặt. Đây là một ví dụ nhỏ: configure.ac: AC_INIT(foobar, 1.0) AC_PR
Tôi muốn sao chép các hàng SQL vào cùng một bảng. Nhưng trong bảng của tôi có một cột "văn bản". Sử dụng SQL này: CREATE TEMPORARY TABLE product2 ENGINE=MEMORY SELECT
Có ai có thể giải thích cho tôi df2 = df1 df2 = df1.copy() df3 = df1.copy(deep=False) không? Tôi đã thử tất cả các tùy chọn và thực hiện như sau: df1 = pd.DataFram
Hazelcast có khả năng sao chép tương tự như Ehcache không? http://www.ehcache.org/generated/2.9.0/pdf/Ehcache_Replication_Guide.
Tôi có cấu trúc mạng như sau. Ubuntu 16.04. Một phiên bản trên Amazon AWS chạy máy chủ MySQL toàn cầu của tôi. Tôi muốn sử dụng máy chủ này như một máy chủ phụ cho nhiều máy chủ cục bộ (máy chủ MySQL của máy Windows)
Sử dụng SQLyog, tôi đang kiểm tra xem các giá trị có đúng được đặt trong bảng hay không. Tôi đã thử SELECT type_service FROM service WHERE email='test@gmail.com' Vì vậy, nó chỉ xuất ra
Ai đó có thể cung cấp một số hướng dẫn về cách cấu hình ElasticSearch để sao chép không? Tôi đang chạy ES trong Windows và hiểu rằng nếu tôi chạy tệp bat nhiều lần trên cùng một máy chủ, một phiên bản ES riêng biệt sẽ được khởi động và
Lưu ý một chút: ThreadGroup có hai phương pháp để sao chép luồng. public int enumerate(Thread list[]) // Tất cả các luồng đang hoạt động trong ThreadGroup sẽ được sao chép vào
Điểm nổi bật của ThreadGroup là hai phương pháp để sao chép một nhóm luồng. public int enumerate(ThreadGroup list[]) // liên quan đến enumerate(list,true)
Tài liệu chính thức của Cassandra nói rằng: Cấu hình không gian khóa và tạo trung tâm dữ liệu mới: Sử dụng ALTER KEYSPAC
Câu hỏi này đã có câu trả lời ở đây: Làm thế nào để làm mịn trọng số theo hệ số tùy ý trong ggplot2? (2 câu trả lời
Chúng tôi có mẫu đơn để thể hiện sự quan tâm đến nhiều câu lạc bộ khác nhau. Đầu ra ghi lại dữ liệu trong bảng tính Excel với tên, họ, email, đại từ ưa thích và số "1" trong cột tương ứng cho câu lạc bộ mà họ quan tâm (mô hình bên dưới). Chúng tôi hy vọng sẽ cung cấp cho câu lạc bộ
Câu hỏi này đã có câu trả lời ở đây: Đã đóng 8 năm trước. Có thể trùng lặp: Trong vim, làm thế nào để tôi có được
Làm thế nào để sao chép một hình dạng và ô chứa hình dạng đó? Khi tôi sao chép thủ công, các hình dạng sẽ theo các ô, nhưng khi tôi sao chép bằng macro, tôi sẽ có mọi thứ ngoại trừ các hình dạng. Cells(sourceRow, sourceColumn).Sao chép C
Tôi là một lập trình viên xuất sắc, rất giỏi!