ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBs scripting for calling excel sreadsheet (https://www.excelbanter.com/excel-programming/340723-vbs-scripting-calling-excel-sreadsheet.html)

Patrick

VBs scripting for calling excel sreadsheet
 
Hi every1!!

Not sure if this is the right section for this but here goes:

I want to right a vbs script that will call an excel template i created.
That template as an Auto_Open macros that needs to be executed.

Then i want to save that excel under diff name and close it.
All this needs to be invisible to user, so i dont need to visually see the
excel spreadsheet open up and everything..

Can this be done!!!

Thx in advance for any help you can provide me with..

PAtrick

Bob Phillips[_6_]

VBs scripting for calling excel sreadsheet
 

Set oWB = workbooks.open Filename:=name_of_file
Application.Run "'" & oWb.Name & "'!Auto_Open"
oWb.Close SaveChanges:=False
Set oWB = Nothing

--
HTH

Bob Phillips

"Patrick" wrote in message
...
Hi every1!!

Not sure if this is the right section for this but here goes:

I want to right a vbs script that will call an excel template i created.
That template as an Auto_Open macros that needs to be executed.

Then i want to save that excel under diff name and close it.
All this needs to be invisible to user, so i dont need to visually see the
excel spreadsheet open up and everything..

Can this be done!!!

Thx in advance for any help you can provide me with..

PAtrick




Dave Patrick

VBs scripting for calling excel sreadsheet
 
All air code but this should get you started.

Option Explicit
Dim filePath1, filePath1, oExcel, oSheet

filePath1 = "c:\Test.xlt"
filePath2 = "c:\Test1.xls"
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Open(filepath1)
oExcel.Run "macro1"
oExcel.DisplayAlerts = False
oExcel.ActiveWorkbook.SaveAs filePath2
oExcel.Close(false, filePath1)
oExcel.Close(false, filePath2)
oExcel.Quit
Set oExcel = Nothing

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Patrick" wrote:
| Hi every1!!
|
| Not sure if this is the right section for this but here goes:
|
| I want to right a vbs script that will call an excel template i created.
| That template as an Auto_Open macros that needs to be executed.
|
| Then i want to save that excel under diff name and close it.
| All this needs to be invisible to user, so i dont need to visually see the
| excel spreadsheet open up and everything..
|
| Can this be done!!!
|
| Thx in advance for any help you can provide me with..
|
| PAtrick



Patrick

VBs scripting for calling excel sreadsheet
 
This is great everything is working now.

Thank you so much!!

"Dave Patrick" wrote:

All air code but this should get you started.

Option Explicit
Dim filePath1, filePath1, oExcel, oSheet

filePath1 = "c:\Test.xlt"
filePath2 = "c:\Test1.xls"
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Open(filepath1)
oExcel.Run "macro1"
oExcel.DisplayAlerts = False
oExcel.ActiveWorkbook.SaveAs filePath2
oExcel.Close(false, filePath1)
oExcel.Close(false, filePath2)
oExcel.Quit
Set oExcel = Nothing

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Patrick" wrote:
| Hi every1!!
|
| Not sure if this is the right section for this but here goes:
|
| I want to right a vbs script that will call an excel template i created.
| That template as an Auto_Open macros that needs to be executed.
|
| Then i want to save that excel under diff name and close it.
| All this needs to be invisible to user, so i dont need to visually see the
| excel spreadsheet open up and everything..
|
| Can this be done!!!
|
| Thx in advance for any help you can provide me with..
|
| PAtrick




Dave Patrick

VBs scripting for calling excel sreadsheet
 
Glad to hear it. You're welcome.

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Patrick" wrote:
| This is great everything is working now.
|
| Thank you so much!!




All times are GMT +1. The time now is 04:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com