Hello all,
I wonder whether and how it's possible to run/start a macro inside an Access-database.
Background: I coded several macros in MS-Access (which e.g. print letters using forms within Access)
and simply want to start them from within my PB 3.94-database application.
 
There need not be any "feedback" to my application, a simple call or click to execute the macro will be sufficient.
Is this possible?
Any snippet or idea will be welcome.
Thanks in advance!
			
			
									
									
						MS-Access: how to run macros from w/i PB?
- 
				Edwin Knoppert
- Addict 
- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
- the.weavster
- Addict 
- Posts: 1581
- Joined: Thu Jul 03, 2003 6:53 pm
- Location: England
This is not a great solution but it will work:
If you create a macro called 'AutoExec' it runs when you first open Access, if you make this a conditional macro it could look up a value in a table and perform a certain function based on what it finds.
So your PB app would write a value to the Access table then launch the database, the AutoExec macro would perform the function associated with the value you have written to the table then quit.
This is a more elegant solution:
If it's just reports you require check out ComponentOne, you can convert reports you have created with MS Access to an XML template. Then it has an ActiveX control that will not only print the report but can output it in a multitude of different formats (*.rtf, *.pdf, *.htm etc...)
			
			
									
									
						If you create a macro called 'AutoExec' it runs when you first open Access, if you make this a conditional macro it could look up a value in a table and perform a certain function based on what it finds.
So your PB app would write a value to the Access table then launch the database, the AutoExec macro would perform the function associated with the value you have written to the table then quit.
This is a more elegant solution:
If it's just reports you require check out ComponentOne, you can convert reports you have created with MS Access to an XML template. Then it has an ActiveX control that will not only print the report but can output it in a multitude of different formats (*.rtf, *.pdf, *.htm etc...)
- the.weavster
- Addict 
- Posts: 1581
- Joined: Thu Jul 03, 2003 6:53 pm
- Location: England
I was just looking at www.PureArea.net and noticed in the libraries section there is a library for utilising the MS ScriptControl.
So, you should be able to use MS Access as an Automation Server.
In Access create a module that contains a public procedure that prints your report (I don't think you can call code that's in forms), then you can call this procedure from a script using the ScriptControl library.
			
			
									
									
						So, you should be able to use MS Access as an Automation Server.
In Access create a module that contains a public procedure that prints your report (I don't think you can call code that's in forms), then you can call this procedure from a script using the ScriptControl library.
On german forum ScriptControl lib for PB4 (OpenSource beta):
http://www.purebasic.fr/german/viewtopi ... iptcontrol
			
			
									
									http://www.purebasic.fr/german/viewtopi ... iptcontrol
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

						Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.




