私はユーザーフォーム 'CemeaFinallist'にチェックボックスとボタンがあります。私は変数としてチェックボックス名の値を使用したい= CNN 'Normal.newmacros.minipro'ノーマルマクロでユーザーフォームの値を使用
に続いては、ユーザーフォームのボタンのスクリプト
Private Sub Shift_Click()
CemeaFinallist.Hide
Dim ctl As Control
Dim j As Long
For Each ctl In Me.Controls
If TypeOf ctl Is MSForms.CheckBox Then
If Me.Controls(ctl.Name).Value = True Then
If ctl.Caption = "Select All" Then
Else
Application.Run MacroName:="Normal.NewMacros.minipro"
End If
End If
End If
Next
Application.ScreenUpdating = True
End Sub
以下であるマクロNormal.NewMacrosある
Sub MiniPRO()
Application.ScreenUpdating = False
Dim path As String
Dim CNN As String
Dim ex As String
Dim News As String
Dim SD As String
path = "C:\Documents and Settings\Administrator\Desktop\EMEA CEEMEA\EMEA FOR DAILY USE\"
CNN = ctl.Name 'at this stage Run Time Error '424' Object required'
ex = ".DOCX"
Documents.Open FileName:=path & CNN & ex
コードのどの部分が失敗していますか? – jsotola
実行時エラー '424'オブジェクトが必要です。 'CNN = ctl.Name' –
であなたは' ctl'を宣言していないので、その型はVariantです、 'Dim ctl as Variant'と同じです。値を割り当てていませんが、Nameプロパティを取得してオブジェクトとして使用しようとしています。エラーは、見つかるべき対象がないことを示しています。あなたはMiniPRO 'dim ctlをオブジェクトとして' set ctl = forms( "CemeaFinallist")に 'ctl'オブジェクトを定義する必要があります。checkbox' ....正確なコードではなく、これらの行に沿ったものです – jsotola