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
pdvsaProject financeAsked:
Who is Participating?
 
PatHartmanCommented:
Create a new module in Access.
Create a new procedure in the module.
Paste the script into the new procedure.

After the transferSpreadsheet, add a command to call the new procedure.

Docmd.TransferSpreadsheet .....
Call NewProcName()
0
 
PatHartmanCommented:
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

0
 
pdvsaProject financeAuthor Commented:
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
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
pdvsaProject financeAuthor Commented:
Oh I see.  An expert way to do that.  Will give it a try.  

Thank you
0
 
pdvsaProject financeAuthor Commented:
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.
0
 
PatHartmanCommented:
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 librarySetReference.JPG
0
 
pdvsaProject financeAuthor Commented:
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
0
 
PatHartmanCommented:
Variables should always be defined.
0
 
pdvsaProject financeAuthor Commented:
Ok.  Thank you Pat...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.