Guest miguelfreitas Posted March 31, 2011 Report Share Posted March 31, 2011 Private Sub Comando14_Click() Dim Xl As Excel.Application Dim FileName As String Dim wb As Workbook Dim rng As Range Dim LastRow As Long Dim ws As Worksheet MsgBox ("ola") Set Xl = New Excel.Application FileName = Xl.GetOpenFilename If FileName = "False" Then Exit Sub Set wb = Xl.Workbooks.Open("Produtos.xlsx") Set ws = wb.Worksheets("Produtos") 'Assuming it is Sheet1 LastRow = ws.Range("A100").End(xlUp).Row ws.Range("A2:D" & LastRow).Copy 'Columns to copy DoCmd.OpenTable ("Produtos") 'Opens the table DoCmd.RunCommand acCmdPasteAppend 'Pastes in the worksheet data wb.Saved = True wb.Close Set Xl = Nothing End Sub Tenho isto e dá-me este erro : "Compile Error : User-defined type not defined" Já dei voltas e mais voltas e não consigo resolver o erro 😡 Esse código vba resulta de um botão que serve para fazer importação de um ficheiro excel. Alguém me ajuda a resolver o erro ? Agradeço desde já, Miguel Freitas. Link to post Share on other sites
KeepItSimple 0 Posted April 1, 2011 Report Share Posted April 1, 2011 Estás a tentar definir um objecto do tipo "excel.application". É algo externo ao Access, pelo que tens de "referenciar". Na janela do VBA vais a Tools-->References--> e seleccionas o "Microsoft Excel xx Object Library" (xx varia conforme a versão do Excel). Link to post Share on other sites
Guest miguelfreitas Posted April 4, 2011 Report Share Posted April 4, 2011 Estás a tentar definir um objecto do tipo "excel.application". É algo externo ao Access, pelo que tens de "referenciar". Na janela do VBA vais a Tools-->References--> e seleccionas o "Microsoft Excel xx Object Library" (xx varia conforme a versão do Excel). Txi, aparentemente é uma coisa tão simples de resolver. Muito obrigado KeepItSimple! Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now