Break a link to a data source

G

Guest

I have a template that imports external data (OBDC) and/refreshes upon
startup. Once opened, the user saves the file as a differnent name (.xlt to
..xls). When the user opens up the .xls, it automatically refreshes the data
(problem if a new query was request from our MRP system).

Is there a way with VBA to break the data link once the file is saved as an
..xls?

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Need code here

End Sub
 
G

Guest

Thanks. Had to createa a macro though. If I tried to save the template
(.xlt) with that code in the SaveBefore routine, it killed the link in the
template.
 
D

Dick Kusleika

asmenut

Yeah, that's a problem. You could use OnTime to call a macro that deletes
the query like

Application.OnTime Now+TimeSerial(0,0,0), "DelQuery"

That would run after the BeforeSave is done but it presents another problem.
If the user saves it during the close process (user closes the unsaved
template and chooses yes when prompted to save), the workbook would re-open
to run that macro.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top