Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excel help needed
#1
Hi Gintaras, hi all,

as many, i must declare my income tax, and i do it partially via an excel document.

Situation:

One excel file, containing 12 tabs labeled from january to december.

Rows are free as they will contain the purpose of the income/expense, the amount of it.

Colums are already filled with categories: food, gas, train ticket, professional taxes and so on......

My goal:

say i want to declare i spent for professional travel a 200€ train ticket.
Category is colum H, amount will be in row 4 : so i want QM to put value 200 in cell H:4

i tried all day to achieve that with no luck, by trying to adapt some code in the help files.
(from doc)

str a3 b3
ExcelSheet es.Init
es.GetCell(a3 1 3)
es.GetCell(b3 2 3)
out a3
out b3

This one triggers an error (Error (RT) in Macro name: 0x80004002, Cette interface n’est pas prise en charge) which can be translated to
"this interface is not handled, can not be used ,even is not declared)

I use Office 2007 under Windows 7.

I think i could do better, but i can't find documentation for all the functions if i try to use excel
via the COM interface thing
(from doc)
Excel.Workbook x._getfile("$desktop$\Book5.xls")
Excel.Application a=x.Application
a.Visible=TRUE; err
Excel.Windows ws=a.Windows
Excel.Window w=ws.Item(1)
w.Visible=TRUE

the code works, but i can't go further as i don't understand what mean Workbook, Workbooks, ws and
so on. If you could steer me to the place where i can find the API definitions.....

Thanks in advance.

Laurent
#2
Possibly the first code does not work because QM and Excel run in different UAC integrity levels.
Let the macro run in separate process as User. Set it in Properties dialog.

For the second code reference, look in Excel Help.
F1, Table of Contents, Microsoft Excel Visual Basic Reference.
It is in Excel 2003. I think in 2007 similar.
But easier to use ExcelSheet. You can attach Worksheet to ExcelSheet.

Macro Macro1422
Code:
Copy      Help
Excel.Workbook x._getfile("$personal$\Book2.xls")
Excel.Application a=x.Application
a.Visible=TRUE; err
Excel.Windows ws=a.Windows
Excel.Window w=ws.Item(1)
w.Visible=TRUE

ExcelSheet es
es.ws=x.Worksheets.Item(1)
str s1
es.GetCell(s1 1 1)
out s1

;then can attach other sheet and work with it:
;es.ws=x.Worksheets.Item(2)
;...
#3
HI gintaras,

that did work, you're a magician. no changing user stuff needed.

but i tried to access a specific cell and did:

es.SelectCell(4 9)

and i got:

Error (RT) in My First Macro: 0x80020009, Une exception s’est produite (an exception occurred).
0x3EC: La méthode Select de la classe Range a échoué (Select method of Range class failed.)
#4
Here works. Office 2003, Windows 7, empty sheet. Will test with Office 2007 later.
#5
Same here, works only with empty sheet. Weird.

BTW, how can i have a "what row number am i located in" stuff, it's the last thing i need
to be able to fill my income tax, when the macro work with a filled sheet?

thanks.

PS: if needed, i can send you in PM the file so you can test
#6
Macro Macro1423
Code:
Copy      Help
;/exe 1
ExcelSheet es.Init
int r
es.GetSelectedRange(0 0 r)
out r

yes, PM
#7
Gintaras,

all my problems seems to come from 2 things

1) UAC stuff, as i must run excel as administrator to have all quite working...grrr

2) some routines seem (not sure though) mismatch declarations with my foreign language.
so some windows are not properly identified (class instead of name or title should do the trick).

going deeper.
#8
QM Excel functions don't work with Excel if Excel is running as admin. Maybe because QM running as admin also is uiAccess, which is slightly different from pure admin integrity level.

Let Excel run normally, not as admin. Let macros that use Excel functions run in separate process as User. You can set it in Properties dialog.

ExcelSheet does not use Excel window name or class. Only program name. Isn't it EXCEL?
#9
Hmmm.. pretty weird as using excel as admin
is the only way here to get ExcelSheet library
behave correctly.

Yes it's EXCEL but i don't have a regular instalkation
setup maybe that explains

And running as user option seems to make an exe
file and i hate to mess up my QM dir
#10
Macro Macro1432
Code:
Copy      Help
;/exe 1

;...


;BEGIN PROJECT
...
;exe_file  $my qm$\xxxxx.exe
...
;END PROJECT

Replace $my qm$ to $temp$. It will create the exe file in your temporary folder.
#11
Nice...

OK three unrelated more:

1. is it possible in shell menu to define an icon for top menu (not items)?

2. is there a way to remap keys as Fn ones on my netbook?

3. a way to start action on key press (say alt+A) and then different action press 1 alone after the sequence or
alt+A+1 directly...stuck in that.

tried to find for 1. did not search for 2.
#12
1. Create new empty macro. Assign shell menu trigger with icon, and also check Submenu checkbox. The macro will be used only for the submenu and will not run.

2. It will be in next QM, this month.
Fn probably cannot be remapped to a modifier key (Shift etc) because does not have "pressed" state.

3.
Macro Macro1439
Trigger Aa     Help - how to add the trigger to the macro
Code:
Copy      Help
out "action 1"
rep
,wait 0 KF 1
,out "action 2"
#13
Great news.

Excel cells filling for income tax time has come.....

Thanks for all.
#14
Add items to it.

this is a submenu macro
Macro Macro1441
Trigger ^Shell_menu "QM submenu with icon" 0x8008 "" "$qm$\qm.exe,0"     Help - how to add the trigger to the macro

this is a macro in the submenu
Macro Macro1442
Trigger ^Shell_menu "QM submenu with icon\macro"     Help - how to add the trigger to the macro
Code:
Copy      Help
function $files
mes files
#15
Ok, what does the submenu thing do exactly, as i did not find help...in help section!
#16
.................


Attached Files Image(s)
   
#17
yes that is exactly what i want, plus an icon to submenus though.

Does your code do that?
#18
Yes.
Create two macros, copy the triggers from my previous post, and paste in the Trigger field in the toolbar for each macro. Then right click a file in Explorer. You'll see a submenu with QM icon, containing 1 item.
#19
If you already have a submenu, it is automatically created when labels of submenu items are like "Submenu Name\Item Name".

To add icon to the submenu, create macro for it. Name and text not important. Assign shell menu trigger. Let Label be "Submenu Name". Assign icon and check Submenu.
#20
The help is in one of System macros. I forgot to make it easily accessible. Here it is.

Macro Shell menu triggers help
Code:
Copy      Help
,;ABOUT

;Adds macros to the shell menu. The menu is shown when you
;right-click a file in Windows Explorer, Desktop, etc.


,;HOW TO ADD A MACRO TO THE SHELL MENU

;To add a macro to the shell menu, assign it trigger of
;"Shell menu" type (in Properties). The macro runs when you
;click the menu item. It receives the list of selected files.

;To add the macro to the shell menu, specify at least menu
;item label. To add it to a submenu, enter submenu label,
;backslash, and menu item label, eg Submenu\My Macro.
;The submenu is created automatically if does not exist
;(read more below).

;By default, the macro is added to the menu for all files.
;To add it only for certain file types, enter one or more
;extensions separated by space, eg txt doc rtf. For files
;with no extension, use <noextension>.

;If you specify one or more strings in "Folders" field,
;the menu item will be displayed only if the path of the
;selected file(s) begins with one of these strings.

;You can specify an icon file for the menu item, eg &my
;qm$\xxx.ico. It can be ico, bmp or other file. You can
;specify icon index, eg icons.dll,4. In the main menu don't
;use many icons from executable files, because they are
;extracted slowly.

;Description - text that Windows Explorer will display in
;the status bar.
;
;You don't have to explicitly create macros for submenus,
;unless you want to assign file types, icon and
;description to the submenu. If you assign file types to a
;submenu, you don't have to assign file types to its child
;items, unless you want to assign them only some of these
;file types, or except some of these file types.


,;NOTES

;The number of menu items you can add is limited. On WinXP
;it is ~150.

;Part of the trigger type is implemented as user-defined
;trigger. Another part is qmshlex.dll.

;When there are one or more non-disabled triggers of this
;type, you can see shell_menu_triggers in the Threads list.
#21
No menu appearing, and a message saying

Warning: trigger function Keyboard_2 not found. This trigger will not work.
#22
Import this file.


Attached Files
.qml   shell menu trigger.qml (Size: 314 bytes / Downloads: 330)
#23
OK, only the first one works, after i installed archive.qml from the site....
But the second one refuses to work
#24
Keyboard_2 probably was an user-defined trigger downloaded from forum and later deleted. Probably some your macros have this trigger assigned.
#25
What does not work?
Don't need Archive for shell menu triggers.
Keyboard_2, if does not work, probably is disabled, or in disabled folder.
#26
OK, seems to work now, i was idiotic to check "submenu" property on the...submenu (aka 2nd item) menu.
Assigning an icon to the submenu does give an icon to it too.
QM is hard to tame sometimes.....

Thanks for your patience Gintaras, you're an angel
#27
Thank you too.
#28
Victory is mine (hmmm yours !!)


Attached Files Image(s)
   


Forum Jump:


Users browsing this thread: 1 Guest(s)