Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 File IO from DTS ActiveX - VB

Author  Topic 

beh
Starting Member

2 Posts

Posted - 2007-11-28 : 12:21:46
Hi, I'm using the following script to run 2 macros, one to delete all worksheets (except one) and then one to recreate them.

**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************
Function Main()
'References to Excel
dim xl_app
dim xl_Spreadsheet

SET xl_app = CREATEOBJECT("Excel.Application")
SET xl_spreadsheet = xl_app.Workbooks.Open _
(DTSGlobalVariables("gv_str_SpreadsheetName").Value)

'Run the macro
xl_app.Run DTSGlobalVariables("gv_str_Macro_Delete").Value

xl_app.Run DTSGlobalVariables("gv_str_Macro_Create").Value

'Very important to clean up.
'if you make changes to a spreadsheet then XL will ask you if you want to save
'it on closing so let's pre-empt it and save the workbook then close

xl_spreadsheet.Save
xl_spreadsheet.Close

xl_app.Quit
set xl_app = Nothing

Main = DTSTaskExecResult_Success
End Function


The above works fine. However, I also need to:

1) - Create a copy of my template (which contains buy of my macros) - This is the file with the address held in -->gv_str_SpreadsheetName
2) - Rename the old file with the date
3) - Rename the copy to the original file name.


Can you please help me !!

Regards,
Paul

anonymous1
Posting Yak Master

185 Posts

Posted - 2007-11-28 : 15:27:12
you can accomplish those using the filesystemobject, maybe file too...
http://msdn2.microsoft.com/en-us/library/6tkce7xa.aspx
Go to Top of Page

beh
Starting Member

2 Posts

Posted - 2007-11-29 : 04:24:30
thanks for your reply. I'll have a go with the filesystem object :)

Go to Top of Page
   

- Advertisement -