Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Question about running macro from VBS

I am using the following script that will allow me to open up excel and run a
macro that is in it. It works fine but what I would like is that when it is
done, instead of asking me if I would like to just save the workbook It would
save the workbook with the data in cell B2 as the file name with the date
appended to the name in the same directory as the original workbook.

Here is what I am using right now. WhoMadeComments is the workbook name and
Get_Data is the macro

Set objXL = CreateObject("Excel.Application")
on error resume next

With objXL
.Workbooks.Open ("D:\Documents and
Settings\user\Desktop\testing\WhoMadeComments.xls" )
.Run "WhoMadeComments.xls!Get_Data"
.Quit
End With
Set objXL = Nothing
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Question about running macro from VBS

Try the below

With objXL
.Workbooks.Open ("D:\Documents and
Settings\user\Desktop\testing\WhoMadeComments.xls" )
.Run "WhoMadeComments.xls!Get_Data"
.SaveAs .ThisWorkbook.Path & "\" & .Range("B1").Text & _
Format(Date, "dd-mm-yyyy") & ".xls"
.Quit
End With


If this post helps click Yes
---------------
Jacob Skaria


"Bobbo" wrote:

I am using the following script that will allow me to open up excel and run a
macro that is in it. It works fine but what I would like is that when it is
done, instead of asking me if I would like to just save the workbook It would
save the workbook with the data in cell B2 as the file name with the date
appended to the name in the same directory as the original workbook.

Here is what I am using right now. WhoMadeComments is the workbook name and
Get_Data is the macro

Set objXL = CreateObject("Excel.Application")
on error resume next

With objXL
.Workbooks.Open ("D:\Documents and
Settings\user\Desktop\testing\WhoMadeComments.xls" )
.Run "WhoMadeComments.xls!Get_Data"
.Quit
End With
Set objXL = Nothing

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Question about running macro from VBS

For some reason the new additions didn't do anything.

"Jacob Skaria" wrote:

Try the below

With objXL
.Workbooks.Open ("D:\Documents and
Settings\user\Desktop\testing\WhoMadeComments.xls" )
.Run "WhoMadeComments.xls!Get_Data"
.SaveAs .ThisWorkbook.Path & "\" & .Range("B1").Text & _
Format(Date, "dd-mm-yyyy") & ".xls"
.Quit
End With


If this post helps click Yes
---------------
Jacob Skaria


"Bobbo" wrote:

I am using the following script that will allow me to open up excel and run a
macro that is in it. It works fine but what I would like is that when it is
done, instead of asking me if I would like to just save the workbook It would
save the workbook with the data in cell B2 as the file name with the date
appended to the name in the same directory as the original workbook.

Here is what I am using right now. WhoMadeComments is the workbook name and
Get_Data is the macro

Set objXL = CreateObject("Excel.Application")
on error resume next

With objXL
.Workbooks.Open ("D:\Documents and
Settings\user\Desktop\testing\WhoMadeComments.xls" )
.Run "WhoMadeComments.xls!Get_Data"
.Quit
End With
Set objXL = Nothing

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Question about running macro from VBS

Hi Bobbo

There were few errors in my previous post..Try the below which uses a
workbook object. I have tried this with a dummy file. Test and feedback...In
case you have any probs; remark the resume next and place msgbox after each
line and idendity where it is returning an error..

Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.Workbooks.Open ("D:\Documents and
Settings\user\Desktop\testing\WhoMadeComments.xls" )

On error resume next

objXL.Run "WhoMadeComments.xls!Get_Data"
objWB.SaveCopyAs objWB.Path & "\" & objWB.ActiveSheet.Range("B1") & ".xls"
objXL.DisplayAlerts = False
objXL.Quit

Set objXL = Nothing
Set objWB = Nothing
Msgbox "Done"

If this post helps click Yes
---------------
Jacob Skaria


"Bobbo" wrote:

For some reason the new additions didn't do anything.

"Jacob Skaria" wrote:

Try the below

With objXL
.Workbooks.Open ("D:\Documents and
Settings\user\Desktop\testing\WhoMadeComments.xls" )
.Run "WhoMadeComments.xls!Get_Data"
.SaveAs .ThisWorkbook.Path & "\" & .Range("B1").Text & _
Format(Date, "dd-mm-yyyy") & ".xls"
.Quit
End With


If this post helps click Yes
---------------
Jacob Skaria


"Bobbo" wrote:

I am using the following script that will allow me to open up excel and run a
macro that is in it. It works fine but what I would like is that when it is
done, instead of asking me if I would like to just save the workbook It would
save the workbook with the data in cell B2 as the file name with the date
appended to the name in the same directory as the original workbook.

Here is what I am using right now. WhoMadeComments is the workbook name and
Get_Data is the macro

Set objXL = CreateObject("Excel.Application")
on error resume next

With objXL
.Workbooks.Open ("D:\Documents and
Settings\user\Desktop\testing\WhoMadeComments.xls" )
.Run "WhoMadeComments.xls!Get_Data"
.Quit
End With
Set objXL = Nothing

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Total Question Sam Excel Worksheet Functions 2 January 31st 12 11:27 PM
Running Sum question LisaK Excel Worksheet Functions 5 January 8th 08 11:59 PM
Running total question Mike Hyndman Excel Worksheet Functions 7 January 23rd 07 08:17 AM
running maximum (newbie question) [email protected] Excel Discussion (Misc queries) 7 May 22nd 06 02:13 AM
Running Macros question gifer Excel Programming 0 May 17th 05 04:06 PM


All times are GMT +1. The time now is 01:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"