Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear,
I have an application that contains a macro, however, are experiencing an issue where I can not select a cell in excel. The problem is in line 31, as follows:
xlSheet.Range ("A1"). select
The message that appears is as follows: "The Select method of Range class failed"
Sub Exportar_Objetos_Excel
'====================================
'LEGENDA SET:
' objExcel = Arquivo do Excel
' xlSheet = Sheet DataBase
' xlDoc = Documento Aberto
'====================================
'Setando um excel application
SET objExcel = CreateObject("Excel.Application")
'Abrindo o relatório
objExcel.Workbooks.Open("C:\Users\rafael.limeira\Documents\Trabalhos - Rafael\01-Planejamento Nacional\Trabalhos\Relatórios\04 - Operadoras\CLARO.ES - Estoque e Vendas\Documento de Parâmetros\Estoque e Vendas Claro ES - 05 Maio 2014.xlsx")
'Setando a Workbook
SET xlDoc = objExcel.ActiveWorkbook
'Verifica se quer mostrar ou não a planilha
objExcel.Visible = True
'Setando a sheet DataBase
SET xlSheet = xlDoc.Worksheets("DataBase")
'Setando o objeto que será exportado
Set Objetos = ActiveDocument.GetSheetObject("CH02")
xlSheet.Range("A1").select
'Exportando os dados
ActiveDocument.GetSheetObject("CH02").CopyTableToClipboard True
xlSheet.Paste
'Alinhar as colunas
xlSheet.Cells.EntireColumn.AutoFit
'Salvar e fechar arquivo
xlDoc.Save
xlDoc.Close (True)
SET xlSheet = Nothing
SET xlDoc = Nothing
objExcel.Quit
SET objExcel = Nothing
End Sub
hugs,
Rafael Limeira
Brazil
I assume you need at first to activate the sheet:
xlSheet.Activate
- Marcus
I assume you need at first to activate the sheet:
xlSheet.Activate
- Marcus
Marcus,
Perfect, thanks!
Rafael