PDA

View Full Version : Run-time error '424'; Object Required in VBA word 2010



incredible22
02-16-2015, 08:27 AM
I created a form in word that used VBA and it has been workingfor a while. Now for some reason an error appears when the form opens andmakes it impossible to use/edit. I receive the error popup "Run-timeerror '424' Object Required".
Below is the code being used, cananyone help me figure out what the error is referring to? Thank you


PrivateSub ComboBox1_DropButtonClick()
ComboBox1.List = Array(" ", "SELECT HERE", "NewHire/Account", "Temp. Employee/Account", "Intern","Role Change", "Department Move", "Leave of AbsenceReturn")
End Sub
Sub AutoOpen()
Dim myArray() As Variant
Dim sourcedoc As Document
Dim i As Integer
Dim j As Integer
Dim myitem As Range
Dim m As Long
Dim n As Long
Application.ScreenUpdating = False
Set sourcedoc = Documents.Open(FileName:="\\data\Public\Roles.docx",Visible:=False)
i = sourcedoc.Tables(1).Rows.Count - 1
j = sourcedoc.Tables(1).Columns.Count
ComboBox2.ColumnCount = j
'Hide columns 2 and 3
ComboBox2.ColumnWidths = "75;0;0"
ReDim myArray(i - 1, j - 1)
For n = 0 To j - 1
For m = 0 To i - 1
Set myitem = sourcedoc.Tables(1).Cell(m + 2, n + 1).Range
myitem.End = myitem.End - 1
myArray(m, n) = myitem.Text
Next m
Next n
'Load data into ListBox1
ComboBox2.List = myArray
sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
lbl_Exit:
Exit Sub
End Sub
Private Sub ComboBox2_Change()
Dim myArray As Variant
'Use Split function to create an array of data
myArray = Split(ComboBox2.List(ComboBox2.ListIndex, 1),VBA.Chr(13))
'Populate listbox2
ComboBox3.List = myArray
End Sub

Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 46, 48 To 57
Case Else
KeyAscii = 0
MsgBox "Only numbers allowed"
End Select
End Sub

gmaxey
02-16-2015, 02:28 PM
What line of code is causing the error? Which one did it stop on? It will help if you put your code in code tags (the "#" icon on the toolbar)