Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cant run code

Status
Not open for further replies.

scrappe7

Technical User
Jul 30, 2001
82
US
I have the following code. it should display a message box asking whether formatting has taken place? if it has then it should run a macro in an xls file. this occurs with amodule in access.

Sub IsFormated()
Dim Answer As Integer
Answer = MsgBox("Is the file formated ?", vbYesNo, "Format")
If Answer = vbYes Then

Dim appExcel As Excel.Application '''''error here'''

Set appExcel = CreateObject("Excel.Application")
appExcel.Visible = True
appExcel.Workbooks.Open "V:\Risk_Mgmt_Credit\Canada monitoring\MacroHolder.xls"
appExcel.Run "Module1.Format_Report"
appExcel.Workbooks("report144alll.xls").Close True

End If
End Sub

the error is a user defind type not defined. what do i do?
please help
 
If I understand correctly, your running this in Access. If that's the case it may be that you haven't added the necessary Reference to excel, you need to creat a reference to the Microsoft Excel type library. I am not familiar with the method for Acces, but in Excel, whilst in the VBA project macro browser, select Tools | References, then select the relevant Microsoft Excel object for the level of Excel you are using.
Hope this helps

macbone2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top