Hello,
I am fairly new a code. I am having a problem with VB code in Access. I am trying to format a report by using the Run Excel command button, but I am running across a compile error "Sub or Function not defined." on Range. Is it necessary to call a function for Range? If so, can someone please help me!!
I would appreciate any input and resolution.
Regards,
MMAX
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim oApp As Object
Set oApp = CreateObject("Excel.Application"
oApp.Visible = True
'Only XL 97 supports UserControl Property
On Error Resume Next
oApp.UserControl = True
'Create a new workbook for import
Workbooks.Add
ChDir "C:\"
Workbooks.OpenText Filename:="C:\component.xls", Origin:=xlWindows, _
StartRow:=68, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(7 _
, 1), Array(23, 1), Array(53, 1), Array(69, 1), Array(77, 1), Array(91, 1), Array(98, 1), _
Array(106, 1), Array(115, 1), Array(124, 1), Array(134, 1), Array(143, 1), Array(152, 1))
ActiveWorkbook.SaveAs Filename:="C:\component.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Range("F9".Select
ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
End Sub
I am fairly new a code. I am having a problem with VB code in Access. I am trying to format a report by using the Run Excel command button, but I am running across a compile error "Sub or Function not defined." on Range. Is it necessary to call a function for Range? If so, can someone please help me!!
I would appreciate any input and resolution.
Regards,
MMAX
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim oApp As Object
Set oApp = CreateObject("Excel.Application"
oApp.Visible = True
'Only XL 97 supports UserControl Property
On Error Resume Next
oApp.UserControl = True
'Create a new workbook for import
Workbooks.Add
ChDir "C:\"
Workbooks.OpenText Filename:="C:\component.xls", Origin:=xlWindows, _
StartRow:=68, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(7 _
, 1), Array(23, 1), Array(53, 1), Array(69, 1), Array(77, 1), Array(91, 1), Array(98, 1), _
Array(106, 1), Array(115, 1), Array(124, 1), Array(134, 1), Array(143, 1), Array(152, 1))
ActiveWorkbook.SaveAs Filename:="C:\component.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Range("F9".Select
ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
End Sub