View Single Post
  #2  
Old 03-08-2006, 04:15 PM
Ardus Petus
Guest
 
Posts: n/a
Re: call multiple macros in workbook_open?

Try this (untested) :

Private Sub Workbook_Open()
dim ws as worksheet
dim qt as querytable

for each ws in ThisWorkbook.Worksheets
for each qt in ws.querytables
.ResultRange.ClearContents
.Delete
next qt
next ws
Call URL_Sheet1_Query
call URL_Sheet2_Query
....

end sub

HTH
--
AP

"slimswol" <slimswol.24dbka_1141850102.2339@excelforum-nospam.com> a écrit
dans le message de
news:slimswol.24dbka_1141850102.2339@excelforum-nospam.com...
>
> Hi,
> I almost have a program running for excel. I am trying to call multiple
> macros from "ThisWorkbook". The code below is supposed to delete the
> current QueryTable and then after the QueryTable is deleted I call a
> macro to add the new data. It currently does work for one
> sheet/QueryTable/Macro. But I am not sure how to do this for multiple
> sheets/QueryTables/Macros ?
>
> MY QUESTION IS HOW DO I DELETE QUERYTABLES AND CALL MULTIPLE MACROS
> FROM THE \"WORKBOOK_OPEN\" FUNCTION?
>
> IF IT IS NOT POSSIBLE, IS THERE ANOTHER WAY TO DO THIS?
>
>
> Private Sub Workbook_Open()
>
>
> With Worksheets("Sheet1_RawData")
>
> QueryTables(1).ResultRange.ClearContents
>
> End With
>
>
> With Worksheets("Sheet1_RawData")
>
> QueryTables(1).Delete
>
> End With
>
>
> Dim qt As QueryTable
>
> For Each qt In Sheets("Sheet1_RawData").QueryTables
> 'Clear QT data
> qt.ResultRange.ClearContents
>
> 'Delete QT named range from workbook
>
> Sheets("Sheet1_RawData").qt(1).Delete
>
> 'Delete query table
> qt.Delete
> Next qt
>
> 'Call macro to run new query
> Call URL_Sheet1_Query
>
> End Sub
>
>
> --
> slimswol
> ------------------------------------------------------------------------
> slimswol's Profile:

http://www.excelforum.com/member.php...o&userid=32014
> View this thread: http://www.excelforum.com/showthread...hreadid=520282
>



Reply With Quote