![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Have searched google but either I am asking the wrong question or it's not been asked before. So could anyone tell me if it's possible to run some vba code in a module in an access database from a scheduled package? Just in case there is a better way of doing what I am doing let me explain why. I have an access database that is linked to an exchange public folder. It has to be access because our SQL server and Exchange server live on different machines. I know if they were on the same machine I could use ODBC link directly (the holy grail for me) from reading around this subject. I therefore created a link in access and wrote a vba sub to refresh it. I then created an identical table in access and upsized it to SQL and wrote another access vba sub to delete all rows from this new table and copy the data from the refreshed exchange linked table. Works fine. Then designed a DTS package (with the wizards help) to import the data from the unlinked table in the access database to the upsized table in SQL. Put a task to delete the contents to prevent duplication and everything works OK there as well. Sheduled it to run regularly. Final part is to get the access to run the two vba routines on a scheduled basis as well. I can do this with autoexec macro and windows task sheduler I think. It occured to me however that it might be possible to get the scheduler in SQL to run a vbscript/activex/something else routine that opened the access DB and called the two vba routines for me. This way I could link the task with workflow on success before destroying the data in SQL tables and re-importing. I have seen that VB can access VBA routines in excel so thought it might be possible here. Is this possible or am I barking up the wrong tree totally and should just run the Access DB through windows scheduler? |
#2
| |||
| |||
|
|
Function Main() 'References to Excel dim xl_app dim xl_Spreadsheet SET xl_app = CREATEOBJECT("Excel.Application") |
#3
| |||
| |||
|
|
"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message news:OKwNKH1WDHA.1268 (AT) TK2MSFTNGP11 (DOT) phx.gbl... [snip] Function Main() 'References to Excel dim xl_app dim xl_Spreadsheet SET xl_app = CREATEOBJECT("Excel.Application") Ooops. Fell at the first hurdle. Woul;d have to install office on the server and it isn't going to happen. Thanks for the code though Alan. Can see uses for that in the future. [snip] -- Ian |
![]() |
| Thread Tools | |
| Display Modes | |
| |