Is it possible to read the active file handle in an excel macro and write data directly to that open file?
VBA active file handle in excel macro
Page 1 of 17 Replies - 2173 Views - Last Post: 05 February 2011 - 04:36 AM
Replies To: VBA active file handle in excel macro
#2
Re: VBA active file handle in excel macro
Posted 30 January 2011 - 04:55 AM
Yes, that are macros for.
#3
Re: VBA active file handle in excel macro
Posted 30 January 2011 - 05:37 AM
Ionut, on 30 January 2011 - 04:55 AM, said:
Yes, that are macros for.
Hi IOnut, sorry maybe I have to express myself a little better:
An excel file i.e. 'a.xls' is open and from this excel file the macro editor is opened. Now I try to find out how I can access the excel file itself, that means I would like to identify the file handle and then use this handle to read or write data to the binary code of this excel file (not to the excel table).
#4
Re: VBA active file handle in excel macro
Posted 31 January 2011 - 08:50 AM
what do you mean? write the file in binary's then how excel open that file?
i think may be i am wrong? make it clear do you want overwrite the cell value(like a mask)
i think may be i am wrong? make it clear do you want overwrite the cell value(like a mask)
#5
Re: VBA active file handle in excel macro
Posted 01 February 2011 - 03:29 AM
If I undestand correct, you want an "old style" manipulation of an xls file, like a binary open in C/C++. This I think can be achived only with WinApi functions. VBA had the purpose to make easier excel files manipulation in a "high level" way: working directly with cell, worksheets, ranges through objects.
If an excel file is open, you cannot write data the way you want. It should get the path, close it and then open the file through winapi.
Quote
An excel file i.e. 'a.xls' is open and from this excel file the macro editor is opened. Now I try to find out how I can access the excel file itself,
If an excel file is open, you cannot write data the way you want. It should get the path, close it and then open the file through winapi.
#6
Re: VBA active file handle in excel macro
Posted 03 February 2011 - 06:50 AM
Ionut, on 01 February 2011 - 03:29 AM, said:
If I undestand correct, you want an "old style" manipulation of an xls file, like a binary open in C/C++. This I think can be achived only with WinApi functions. VBA had the purpose to make easier excel files manipulation in a "high level" way: working directly with cell, worksheets, ranges through objects.
If an excel file is open, you cannot write data the way you want. It should get the path, close it and then open the file through winapi.
Quote
An excel file i.e. 'a.xls' is open and from this excel file the macro editor is opened. Now I try to find out how I can access the excel file itself,
If an excel file is open, you cannot write data the way you want. It should get the path, close it and then open the file through winapi.
Hi IOnut, you are right with your description. I definitely have to change my approach. Thank you very much for your help and time spend.
thava, on 31 January 2011 - 08:50 AM, said:
what do you mean? write the file in binary's then how excel open that file?
i think may be i am wrong? make it clear do you want overwrite the cell value(like a mask)
i think may be i am wrong? make it clear do you want overwrite the cell value(like a mask)
Hi Thava, you are right I did want to write binary to the file and not just change a field or cell. I will look for an other solution. In any case thank you for your contribution. take care.
#7
Re: VBA active file handle in excel macro
Posted 04 February 2011 - 02:17 PM
Ionut is quite right. Read up on the EnumWindows API function: http://msdn.microsof...(v=vs.85).aspx.
Here's the VB translation of the function specification (use the "Windows API Viewer" in VS 6.0 Tools menu folder to find these):
The way this works is you create a Sub, pass the name of the sub to lpEnumFunc using the AddressOf operator, and this function will go through all the top level windows on the screen and call your sub once for each window, passing each handle in as it goes.
HTH
Here's the VB translation of the function specification (use the "Windows API Viewer" in VS 6.0 Tools menu folder to find these):
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
The way this works is you create a Sub, pass the name of the sub to lpEnumFunc using the AddressOf operator, and this function will go through all the top level windows on the screen and call your sub once for each window, passing each handle in as it goes.
HTH
#8
Re: VBA active file handle in excel macro
Posted 05 February 2011 - 04:36 AM
BobRodes, on 04 February 2011 - 02:17 PM, said:
Ionut is quite right. Read up on the EnumWindows API function: http://msdn.microsof...(v=vs.85).aspx.
Here's the VB translation of the function specification (use the "Windows API Viewer" in VS 6.0 Tools menu folder to find these):
The way this works is you create a Sub, pass the name of the sub to lpEnumFunc using the AddressOf operator, and this function will go through all the top level windows on the screen and call your sub once for each window, passing each handle in as it goes.
HTH
Here's the VB translation of the function specification (use the "Windows API Viewer" in VS 6.0 Tools menu folder to find these):
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
The way this works is you create a Sub, pass the name of the sub to lpEnumFunc using the AddressOf operator, and this function will go through all the top level windows on the screen and call your sub once for each window, passing each handle in as it goes.
HTH
Hi Bob,
thanks for your hint, I will try to follow your link ... :-)
might be helpfull for other applications as well ...
blue skies
Gunther Spitzer
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|