Como abrir archivos de Excel desde un botón de comando de un formulario
Publicado por Jose Francisco (166 intervenciones) el 25/05/2019 00:22:18
Buenas tardes estimados , tengo el siguiente código desde un botón de comando de un formulario, abre los directorios, me sitúo en los archivos, pero no logro hacer abrir archivos de excel.
Aguardo alguna respuesta.-
Gracias
Aguardo alguna respuesta.-
Gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
LOCAL lcFile,;
lcCaption,;
loExcel as Object,;
loDoc as Object,;
loex as Exception
lcFile = GETFILE("Xlsx")
IF !EMPTY(lcFile)
TRY
loExcel = CREATEOBJECT("Excel.Application")
CATCH TO loex
FINALLY
ENDTRY
IF VARTYPE(loex)="O"
MESSAGEBOX("No tiene Microsoft Excel ® instalado?",0,"Mensaje")
ELSE
*loExcel.file.Open(m.lcfile)
*loDoc = loExcel.ActiveDocument
loExcel.Visible = .t.
*lcCaption = file.ActiveWindow.Caption + [ - Microsoft Excel]
DECLARE integer FindWindow IN "user32" String, String
*lnHWnd = FindWindow(Null , lcCaption)
DECLARE LONG BringWindowToTop IN "user32" LONG HWND
*BringWindowToTop(lnHWND)
ENDIF
ENDIF
Valora esta pregunta


0