Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / October 2007



Tip: Looking for answers? Try searching our database.

WinAPI macro recorder

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ArmsteR - 15 Oct 2007 13:47 GMT
Hello,

I was wondering if there is some WinAPI macro recorder out there?
Preferably freeware :P

I have no knowledge of API and would like something like that to help
me understand more wahts going on, and give me a quick method to get a
VBA macro i need  produced :)
Thorsten Albers - 15 Oct 2007 16:21 GMT
ArmsteR <davidarmstrong@harronhomes.com> schrieb im Beitrag
<1192452475.974246.64260@q3g2000prf.googlegroups.com>...
> I was wondering if there is some WinAPI macro recorder out there?
> Preferably freeware :P

No, of course not. How should that work? The Windows API is a collection of
libraries providing programmable functions to applications - it isn't a
language, and especially it isn't a macro language. Most of these functions
have parameters and a return code; the paramter values depend on the
individual application. And there presumably doesn't exist any application
consisting of (direct) Windows API calls only; on the contrary some
applications doesn't use direct Windows API calls at all. A Windows
application executes its own code as well as that of supplemental libraries
in response to events (window messages etc.). Sometimes it also calls
functions of the Windows API.
What one can do is monitoring the calls of an application to functions of
the Windows API for which there are some tools to be found in the net. But
it doesen make sense to record these calls and play them later again.

> I have no knowledge of API and would like something like that to help
> me understand more wahts going on, and give me a quick method to get a
> VBA macro i need  produced :)

Get yourself a good documentation on the Windows API. A first start is the
MS developer's network (MSDN). A good documentation is Dan Appleman's
"Visual Basic 5.0 Programmer's Guide to the Win32 API" (which unfortunately
is out of print). Usually (one of) the help file(s) of the application
providing the VBA programming interface offers you some basic informatin on
programming with VBA including the calls to Windows API functions.
After you have learned something about the Windows API in general find the
function you want to call and read the documentation on this function (e.g.
in the MSDN). If you even then don't know how to do it try to get a sample
code. Often there is no difference between calling the Windows API function
from VB and VBA, so a VB sample will do.

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

mr_unreliable - 15 Oct 2007 17:36 GMT
As has already been said, Dan Appleman's book is highly
recommended for using the system api from vb5/6.  It may
be out-of-print, but amazon-dot-com still claims to have
copies available.

http://www.amazon.com/Applemans-Visual-Basic-Programmers-Guide/dp/0672315904

As Appleman's book is a fairly standard programming text
(before vb.net) you may also be able to find a copy in
your local or college library.

As far as "what's going on" you might also consider Charles
Petzold's "Programming Windows 95/98", and Jeffrey Richter's
"Advanced Windows".  Conceded, both of these books are out-
of-date and (probably) out-of-print, and oriented to c++
programmers.  Nevertheless, they explain how the older systems
work in minute detail, and how the system api works.  Granted,
much has changed since these books were written, but it has
also gotten a bit more complicated too. IMHO, learning the
very basic-basics would be a good place to start.

cheers, jw

> Hello,
>
[quoted text clipped - 4 lines]
> me understand more wahts going on, and give me a quick method to get a
> VBA macro i need  produced :)
mr_unreliable - 15 Oct 2007 18:15 GMT
>> Hello,
>>
[quoted text clipped - 4 lines]
>> me understand more wahts going on, and give me a quick method to get a
>> VBA macro i need  produced :)

By any chance, is the vba you are using hosted by a microsoft
product like excel or word?

If so, then both XL and WD have their own "built-in" macro
recorder.

You turn it on (tools/macro/record new macro), and then step
"manually" through the operations you wish to record.  When
you are finished, turn the recorder off.

You then go into the tools/macro/visual basic editor.

The vba code you just recorded will be found under the name you
just gave it (for example: "macro1").

cheers, jw
Thorsten Albers - 16 Oct 2007 01:53 GMT
mr_unreliable <kindlyReplyToNewsgroup@notmail.com> schrieb im Beitrag
<e4UBO60DIHA.5228@TK2MSFTNGP05.phx.gbl>...
> If so, then both XL and WD have their own "built-in" macro
> recorder.
> ...
> The vba code you just recorded will be found under the name you
> just gave it (for example: "macro1").

Right, but it will not record Windows API calls but VBA commands and calls
to methods provided by the application and its objects...

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

ArmsteR - 16 Oct 2007 13:45 GMT
On 16 Oct, 01:53, "Thorsten Albers" <alber...@MOVEuni-freiburg.de>
wrote:
> mr_unreliable <kindlyReplyToNewsgr...@notmail.com> schrieb im Beitrag
> <e4UBO60DIHA.5...@TK2MSFTNGP05.phx.gbl>...
[quoted text clipped - 14 lines]
>                                                        uni-freiburg.de
> ----------------------------------------------------------------------

It is to be used within Excel for the control of external documents in
such that I have a number of drwaing register files which I want to be
able to specify which printers to send the print job to and what
pagesize it should be printed at (page size isn't that big a deal as I
can always just setup seperate printers with default page sizes as dif
things as a work around) But these print jobs are to control different
coduments,  PDF/DWG/DWF/DOC etc etc and a range of pagesizes from A4-
A0.
Thorsten Albers - 16 Oct 2007 14:45 GMT
ArmsteR <davidarmstrong@harronhomes.com> schrieb im Beitrag
<1192538735.858503.36980@e34g2000pro.googlegroups.com>...
> It is to be used within Excel for the control of external documents in
> such that I have a number of drwaing register files which I want to be
[quoted text clipped - 4 lines]
> coduments,  PDF/DWG/DWF/DOC etc etc and a range of pagesizes from A4-
> A0.

This in fact isn't a matter of Windows API programming but of VBA code and
MS Excel objects or, in other words: You don't need the Windows API to do
this. Therefore you should go to a newsgroup related to VBA/MS Excel.

But some hints (seen from MS Excel 97 - unfortunately MS Office 2003 is not
available to me):
- 'jw' correctly has pointed you to the built in VBA macro recorder of MS
office products.
- The page size etc. in MS Excel may be controlled by setting
<MyObject>'.PageSetup...'
- The active printer may be selected by setting 'ActivePrinter'
- The print job is started and controlled by <MyObject>'.PrintOut [...]'

I'm assuming that there is no much difference in this between MS Excel 97
and 2003.

A rough sample sketch:

Dim sPrinterPrev As String
Dim lOrientationPrev As Long

sPrinterPrev$ = Application.ActivePrinter
Application.ActivePrinter = "..."

With Worksheets("MyTable")

 lOrientationPrev& = .PageSetup.Orientation
 .PageSetup.Orientation = xlLandscape

 .PrintOut ' see the optional parameters

 .PageSetup.Orientation = lOrientationPrev&

End With

Application.ActivePrinter = sPrinterPrev$

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

ArmsteR - 16 Oct 2007 15:11 GMT
On 16 Oct, 14:45, "Thorsten Albers" <alber...@MOVEuni-freiburg.de>
wrote:
> ArmsteR <davidarmstr...@harronhomes.com> schrieb im Beitrag
> <1192538735.858503.36...@e34g2000pro.googlegroups.com>...
[quoted text clipped - 51 lines]
>                                                        uni-freiburg.de
> ---------------------------------------------------------------------

You do need WinAPI as The internal VBA for excel will not control
applications outside of excel.

Application.ActivePrinter = sPrinterPrev$   is an internal function
only.  I will need to send windows print commands to the autodesk and
adobe applications and therefore need the API commands for this
control.
Thorsten Albers - 16 Oct 2007 16:21 GMT
ArmsteR <davidarmstrong@harronhomes.com> schrieb im Beitrag
<1192543867.723032.9770@v23g2000prn.googlegroups.com>...
> You do need WinAPI as The internal VBA for excel will not control
> applications outside of excel.
> Application.ActivePrinter = sPrinterPrev$   is an internal function
> only.  I will need to send windows print commands to the autodesk and
> adobe applications and therefore need the API commands for this
> control.

Ah, I haven't paid attention to the words "external documents"...
A rough sketch:

Use FindExecutable() to find the application associated with the external
document.

a) Initiate a DDE (Dynamic Data Exchange) session with that application. Of
course for this it is necessary that both the source and the destination
application do support DDE and do support printing via DDE. MS Excel AFAIK
still supports DDE, if Adobe Acrobat (Reader) and AutoCAD do so as well I
can't tell. For more information on DDE see the MSDN and the MS Excel help
files.

b) Start the application and direct it to open the external document
(ShellExecute()/ShellExecuteEx() with operation/verb 'open'); then send the
appropriate keyboard commands (VB: SendKeys(); better Windows API:
keybd_event()) which let the application print the opened document.

c) Start the application and direct it to print the external document
(ShellExecute()/ShellExecuteEx() with operation/verb 'print').

c) presumably is the best and easiest way for you to go. For more
information read the MSDN documentation on the Windows API functions
FindExecutable() and ShellExecute()/ShellExecuteEx() as well as on the
VB(A) functions declare() and call().

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

ArmsteR - 16 Oct 2007 13:47 GMT
On 16 Oct, 01:53, "Thorsten Albers" <alber...@MOVEuni-freiburg.de>
wrote:
> mr_unreliable <kindlyReplyToNewsgr...@notmail.com> schrieb im Beitrag
> <e4UBO60DIHA.5...@TK2MSFTNGP05.phx.gbl>...
[quoted text clipped - 14 lines]
>                                                        uni-freiburg.de
> ----------------------------------------------------------------------

Oh and all machines are using windows XP with office 2003
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.