Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag for United States of America

asked on

Run a script after export to excel

Experts,

I have button on a form that exports data in an excel forma to a folder.
After I export the data, I right click the file and choose to the script.

I want to automate the script from within Access instead of right clicking the file and running the script.  
Basically I want to remove this extra step and have it all inside of access.  

How can I do this?  

Not sure if my explanation is detailed enough.
Please feel free to ask a question.



thank you
Avatar of PatHartman
PatHartman
Flag of United States of America image

I'm confused.  Are you saying that you want to run code that exists in the spreadsheet you just created or do you want to run code in your Access app?  If in Access, then just add it following the TransferSpreadsheet method.

Private Sub cmdYourButton_Click()
    DoCmd.TransferSpreadsheet ............
    ''your other code goes here
 End Sub

Open in new window

Avatar of pdvsa

ASKER

Pat, yes I want to run the code from in Access.  I have attached the script  It is a .vbs.  Should I place that code where you state above?
Export-to-Outlook-Script.vbs
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdvsa

ASKER

Oh I see.  An expert way to do that.  Will give it a try.  

Thank you
Avatar of pdvsa

ASKER

Pat,

Sorry to pester you once again.  
Possibly you could provide me a solution to the "variable not defined" error I get on this line:
strFil = WScript.Arguments(0)

thank you Pat.
Sorry.  I haven't done this in a while.  You need to set a reference to the Scripting runtime library.

Open any code module.
Tools/References
You'll see the following dialog.
Scroll to select the Scripting libraryUser generated image
Avatar of pdvsa

ASKER

Hi Pat, thank you for the follow up.  I sincerely appreciate it.  Unfortunately, that did not fix the issue.   Wondering if you have any other ideas to fix the "variable not defined" error?  I might post another question if this might be a little more complicated than I assume.  I did try to add other scripting references.  Acteually I added all the ones I could find but still had the error.  Not sure if I need to define this Wscript variable it in the first line between the ().

thank you
Variables should always be defined.
Avatar of pdvsa

ASKER

Ok.  Thank you Pat...