WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

COMCONTROL
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Excel In WIL Dialog


Update: This code seems to nolonger work with current versions of Windows. Apparently xls file can no longer be embedded in HTML, possibly for security reasons.
;   this uses MSIE to host Excel...and it can update and change the workbooks
;   displayed inside the Dialog in real-time which is what I think you're looking
;   for...

;   change the variable called DAPATH to your own.

;   however there is still a conflict if an "outside version" of excel is running
;   before the dialog starts. I don't think there's anyway around that.

;   Try testing without excel running first. See the button NEW WORKSHEET. When you
;   click it, it'll find out the name of the current workbook in the dialog. Then it'll
;   prompt you to find another XLS and then load that if it's not the same.

;   Unfortunately if Excel is already running, when you click NEW WORKSHEET, you'll
;   see the name of the ws that's running in Excel outside the dialog. I don't think
;   there's a way around that.

;   Maybe Stan/Jim can give you better explanation.

;   Jay Alverson Winbatch 2007C, Excel 2003, MSIE 6.

#DefineSubRoutine Main(Proc_Handle,Proc_Message,Proc_ID, Proc_EventInfo, reserved)
   ;DialogprocOptions Constants
   MSG_INIT = 0                ; The one-time initialization
   MSG_TIMER = 1                ; Timer event
   MSG_BUTTONPUSHED = 2        ; Button press.
   ; New options for DialogObject
   DLGOBJECT_ADDEVENT   = 1 ;DialogObject add event
   DLGOBJECT_REMOVEVENT = 2 ;DialogObject remove event
   DLGOBJECT_GETOBJECT  = 3 ;DialogObject get reference to object
   DLGOBJECT_GETPICTURE = 4 ;DialogObject get a picture object
   ; New callback message
   MSG_COMEVENT         = 14 ;COM control event fired
   ;
   Switch Proc_Message
   Case MSG_INIT
      ie = DialogObject(Proc_Handle, 007, DLGOBJECT_GETOBJECT)
      ie.navigate(formz)
;      DialogObject(Proc_Handle, 003, DLGOBJECT_ADDEVENT,  "onclick", 1)      ;setup a MSG_COMEVENT
      DialogProcOptions(Proc_Handle, MSG_BUTTONPUSHED, 1)
      DialogProcOptions(Proc_Handle, 1002, 4)
;      DialogProcOptions(Proc_Handle, 1, 500)   ; setup a MSG_TIMER
      Return(-1)
      Break
   Case MSG_BUTTONPUSHED
;
         If Proc_ID == 11
            currentXL = ie.document.application.workbooks(1).name
            Message("Debug", currentXL)
            xlsFiles = FileItemize(StrCat(daPath, "*.xls"))
            newXL = AskItemlist("Excel Workbooks", xlsFiles, @TAB, @SORTED, @SINGLE)
            If newXL == currentXL Then Return(-2)  ; don't bother...
            newXL = StrCat(daPath, newXL)
            ie.navigate(newXL)
            Return(-2)
         EndIf
      Break
   Case MSG_COMEVENT
      ; Test in case more events or COM controls are added later
      If Proc_EventInfo.identifier == 1 && Proc_ID  == 003
         ; Get event source object associated with the event
         Element = document.parentWindow.event.srcElement
         Element = 0
      EndIf
      Break
   EndSwitch       ; Proc_Message
   Return(-1)      ; Do default processing
#EndSubRoutine   ; End of Dialog Callback ExamProc

daPath = "c:\temp\data\"  ;<-- change to your path...

slist = ""
For x = 1 To 10
   slist = ItemInsert(x, -1, slist, @TAB)
Next

formz = StrCat(daPath, "cars.csv")

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`WIL Dialog 2`
MyDialogX=-01
MyDialogY=-01
MyDialogWidth=508
MyDialogHeight=339
MyDialogNumControls=011
MyDialogProcedure=`Main`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`039,199,036,012,PUSHBUTTON,DEFAULT,"Quit",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`013,063,088,078,CALENDAR,pickday,DEFAULT,DEFAULT,6,DEFAULT,DEFAULT`
MyDialog003=`039,177,036,012,PUSHBUTTON,DEFAULT,"OK",1,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`039,157,038,012,PUSHBUTTON,DEFAULT,"Maintenance",3,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog005=`029,249,062,064,ITEMBOX,slist,DEFAULT,DEFAULT,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog006=`017,233,080,010,STATICTEXT,DEFAULT,"Other Work for today . . .",DEFAULT,7,512,"Microsoft Sans Serif|5632|70|34","0|0|128","0|255|128"`
MyDialog007=`115,009,384,314,COMCONTROL,DEFAULT,"about:blank",DEFAULT,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog008=`009,011,090,012,STATICTEXT,DEFAULT,"DATACENTER",DEFAULT,8,DEFAULT,"Microsoft Sans Serif|10752|170|34","0|0|128",DEFAULT`
MyDialog009=`005,031,098,012,STATICTEXT,DEFAULT,"WorkSchedule",DEFAULT,9,512,"Microsoft Sans Serif|10752|170|34","255|255|0",DEFAULT`
MyDialog010=`387,001,112,008,STATICTEXT,DEFAULT,". . . use CTRL+S to save now . . .",DEFAULT,4,512,"Microsoft Sans Serif|5632|170|34","255|0|0",DEFAULT`
MyDialog011=`031,217,052,012,PUSHBUTTON,DEFAULT,"New Worksheet",77,11,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

Article ID:   W17395
File Created: 2012:03:28:08:48:14
Last Updated: 2012:03:28:08:48:14