Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I realise this is probably a very simple question but I would be grateful
for any help offered. I have a workbook that has formula's linked to another worksheet. Unfortunately the sheet it is linked to is a csv file so the links will not update without the sheet being open. Therefore I wanted to write a makro that opens the csv file and then closes it again. I have managed to do that with the record Makro command however I do not know how to get this Makro to run automatically on the worksheet being opened. ChDir "H:\SHARED" Workbooks.Open Filename:="H:\SHARED\susprecpt.csv" ActiveWindow.Close ActiveSheet.ShowAllData Thanks for your help Rob |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
go into the VBE and click on the ThisWorkbook entry for your project in the
project explorer. Select view code and this should produce the Workbook level module. In the dropdowns at the top of the module select Workbook from the left one and Open from the right one. This should put in the sub declarations: Private Sub Workbook_Open() End Sub Put your code in this procedure Private Sub Workbook_Open() ' you don't need to Chdir to open the file 'ChDir "H:\SHARED" Workbooks.Open Filename:="H:\SHARED\susprecpt.csv" ActiveWindow.Close If Activesheet.AutoFilterMode = True then ActiveSheet.ShowAllData End Sub End sub See Chip Pearson's page on Events http://www.cpearson.com/excel/events.htm -- Regards, Tom Ogilvy "Rob Fenn ntlworld.com" <robfenn.mp<at wrote in message ... I realise this is probably a very simple question but I would be grateful for any help offered. I have a workbook that has formula's linked to another worksheet. Unfortunately the sheet it is linked to is a csv file so the links will not update without the sheet being open. Therefore I wanted to write a makro that opens the csv file and then closes it again. I have managed to do that with the record Makro command however I do not know how to get this Makro to run automatically on the worksheet being opened. ChDir "H:\SHARED" Workbooks.Open Filename:="H:\SHARED\susprecpt.csv" ActiveWindow.Close ActiveSheet.ShowAllData Thanks for your help Rob |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to: Open closed workbook/Search data tables/Return data to open workbook | Excel Discussion (Misc queries) | |||
Saving a workbook with a makro | Excel Discussion (Misc queries) | |||
Opening Excel, Book1 opens, remains open with other workbook open | Excel Discussion (Misc queries) | |||
how do i open a data workbook when i open a timesheet workbook | Excel Discussion (Misc queries) | |||
How do you program so that Workbook B cannot be open unless Workbook A is open? Plus I need to validation | Excel Programming |