dbTalk Databases Forums  

DTS - Run Excel macro on Separate spradsheet

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss DTS - Run Excel macro on Separate spradsheet in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
BJ
 
Posts: n/a

Default DTS - Run Excel macro on Separate spradsheet - 10-08-2003 , 02:46 PM






Function Main()
Dim xlApp


Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Open DTSGlobalVariables
("gvTemplateMacro").Value
xlApp.Workbooks.Open DTSGlobalVariables
("gvTemplateFile").Value
xlApp.Run ("Quail")
xlApp.ActiveWorkbook.Close True
xlApp.Quit

Set xlApp = Nothing
Main = DTSTaskExecResult_Success

End Function

When this code is run it errors saying Quail cannot be
found.
Quail is on gvTemplateMacro and I trying to open
gvTemplateFile
and apply the macro.

Is there a way to do this?


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: DTS - Run Excel macro on Separate spradsheet - 10-08-2003 , 03:00 PM






Not tested but what happens if you create 2 Excel.Application instances
instead of just the one ?

--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"BJ" <bjrichard21 (AT) hotmail (DOT) com> wrote

Quote:
Function Main()
Dim xlApp


Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Open DTSGlobalVariables
("gvTemplateMacro").Value
xlApp.Workbooks.Open DTSGlobalVariables
("gvTemplateFile").Value
xlApp.Run ("Quail")
xlApp.ActiveWorkbook.Close True
xlApp.Quit

Set xlApp = Nothing
Main = DTSTaskExecResult_Success

End Function

When this code is run it errors saying Quail cannot be
found.
Quail is on gvTemplateMacro and I trying to open
gvTemplateFile
and apply the macro.

Is there a way to do this?




Reply With Quote
  #3  
Old   
BJ
 
Posts: n/a

Default Re: DTS - Run Excel macro on Separate spradsheet - 10-09-2003 , 04:42 PM



Thanks Allen

The following code works!
Dim xlApp


Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Open DTSGlobalVariables
("gvTemplateMacro").Value

xlApp.Workbooks.Open DTSGlobalVariables("gvBGC").Value
xlApp.Run ("MACRO.xls!Module1.MACRO")
xlApp.ActiveWorkbook.Save

xlApp.Workbooks.Open DTSGlobalVariables("gvHGC").Value
xlApp.Run ("MACRO.xls!Module1.MACRO")
xlApp.ActiveWorkbook.Save

xlApp.Workbooks.Open DTSGlobalVariables("gvOVGC").Value
xlApp.Run ("MACRO.xls!Module1.MACRO")
xlApp.ActiveWorkbook.Save

xlApp.Workbooks.Open DTSGlobalVariables("gvBPGC").Value
xlApp.Run ("MACRO.xls!Module1.MACRO")
xlApp.ActiveWorkbook.Save

xlApp.Workbooks.Open DTSGlobalVariables("gvMDLLC").Value
xlApp.Run ("MACRO.xls!Module1.MACRO")
xlApp.ActiveWorkbook.Save

xlApp.ActiveWorkbook.Close True

xlApp.Quit

Set xlApp = Nothing
BJ
Quote:
-----Original Message-----
Not tested but what happens if you create 2
Excel.Application instances
instead of just the one ?

--
--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"BJ" <bjrichard21 (AT) hotmail (DOT) com> wrote in message
news:042401c38dd4$ec10c110$a301280a (AT) phx (DOT) gbl...
Function Main()
Dim xlApp


Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Open DTSGlobalVariables
("gvTemplateMacro").Value
xlApp.Workbooks.Open DTSGlobalVariables
("gvTemplateFile").Value
xlApp.Run ("Quail")
xlApp.ActiveWorkbook.Close True
xlApp.Quit

Set xlApp = Nothing
Main = DTSTaskExecResult_Success

End Function

When this code is run it errors saying Quail cannot be
found.
Quail is on gvTemplateMacro and I trying to open
gvTemplateFile
and apply the macro.

Is there a way to do this?



.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.