Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combobox of excel sheets
#1
How can I get a dialog with combobox of excel sheets, and activate one of them?
#2
You can open up file properties to get a list of sheets (File, Properties, Contents tab). I was successful at counting the number of items and selecting the items, but I tried to get text from the list and got garbage back.
I used the builtin functions LB_GetCount,LB_GetItemText, and LB_SelectItem. I'll try VB next.
Matt B.
Matt B
#3
Function Excel_Sheets_Dialog
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 223 135 "Form"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 ComboBox 0x54230243 0x0 8 8 96 213 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2010601 "" ""


ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam); ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
typelib Excel {00020813-0000-0000-C000-000000000046} 1.2 0 1
Excel.Application app
Excel.Worksheet ws
sel wParam
,case CBN_SELENDOK<<16|3
,_i=CB_SelectedItem(lParam)
,app._getactive
,ws=app.Worksheets.Item(_i+1)
,ws.Activate
,
,case CBN_DROPDOWN<<16|3
,_i=CB_SelectedItem(lParam)
,app._getactive
,str s
,foreach ws app.Worksheets
,,s+ws.Name; s+"[]"
,TO_CBFill lParam s
,
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1

Show it
Code:
Copy      Help
str controls = "3"
str cb3
if(!ShowDialog("Excel_Sheets_Dialog" &Excel_Sheets_Dialog &controls)) ret

To paste in QM, use menu Edit -> Other formats -> Paste escaped.
#4
Thanks.


Forum Jump:


Users browsing this thread: 4 Guest(s)