Daniel2001
02-05-2008, 01:11 AM
I have a "master" file which opens and activates the other 4 files . The otehr 4 files are written to get data inside them updated when they are open. when i run the 4 files seperately ,they are fine. but using this master file way, only 1 file can get updated! only one specific file. the other 3 files are open and activated( i can see that from the screen),but they don't get updated!! how come?
 
the code in Master file is like:
------------------------------------------------------------
dim wk as workbook
 
set wk = workbooks.open (path of file 1)
wk.activate
 
set wk =workbooks.open (path of file 2)
wk.activate
 
 'same goes for the other 2 file
 
end sub
-------------------------------------------------
Thanks for any help!!and advice ,discussion!
 
by theway, the specific fle that gets updated, the code getting dataupdated is written in workbook_open . the other 3 files ,the code getting dateupdated is written in stardand modules called updating() ,and in their workbook_open(), there is "call updating".
does this way matter ???
Norie
02-05-2008, 05:41 AM
Daniel
 
How can we tell without actually seeing the code that's doing the updating?
Daniel2001
02-05-2008, 02:27 PM
Daniel
 
How can we tell without actually seeing the code that's doing the updating?
Hi, Norie,
 
  THanks for replying..alright , I will give out everything I have.
There are 4 files that needs doing updating 
 
File1.xls 'code :
----------------------------------------------------------
Private Sub Workbook_Open()
Application.Run "EwUpdateAll"   '-- This line does Updating job.
Dim i As Integer                     '-- EwupdateAll is an add-in
Dim ChartObject As ChartObject
i = 3  
For Each ChartObject In ActiveWorkbook.ActiveSheet.ChartObjects
ChartObject.Chart.Export"S:\MARKETS_INET\auto_upload\pdf_ubeskyttede_dk\chart" & i & ".pdf", "jpg" 
  i = i - 1
Next ChartObject
ThisWorkbook.Save
End Sub
------------------------------------------------------------
This file has no problems at all,either it is executed alone, or in the master file .
What this file does :
The add-in fills some new data in the cells based on which 3 charts would be produced .
 
File 2-4 ( all same code, just different data from Financial database)
The data in these files has an increasing charateristic. Every day, there is a New line of Data,so the data increases! and I need to create chart everyday based on daily data. Besides this, there is a column of static history financial data ,these data are unchanged and not updated. 
So there is 3 columns
1) date column
2) updating data column
3) history data column
the chart would be created by two series,updating data and history data.
---------------------------------------------------------------
Private Sub Workbook_Open()
'define variables
   Dim str As String
   Dim str2 As String
   Dim str3 As String
   Dim firstdate As String
   Dim Lastdate As String
   Dim firstDyn As String
   Dim firstdyndate As String
   Dim lastdyndate As String
   Dim FirstHistory As String
   Dim lasthistory As String
   Dim mychtobj As ChartObject
   Dim rownum As Integer
   Dim colnum As Integer
   
'updates data
Application.Run "EwUpdateAll"
 
  ' Date column -- eg.2008-01-07
   firstdate = "r1c1"
   Lastdate = ActiveSheet.UsedRange.End(xlDown).Address(ReferenceStyle:=xlR1C1)  '--since it increases everyday,so i use Usedrange
 
  ' Ecowin date column
   firstDyn = "r1c2"
   firstdyndate = "b272"
   lastdyndate = Range(firstdyndate).End(xlDown).Address(ReferenceStyle:=xlR1C1)
 
   'History date
   FirstHistory = "r1c3"
   rownum = ActiveSheet.UsedRange.Rows.Count
   colnum = 3 'ActiveSheet.UsedRange.Columns.Count
   lasthistory = ActiveSheet.Cells(rownum, colnum).Address(ReferenceStyle:=xlR1C1)
 
  'date column
   str = "=Sheet1!" & firstdate & ":" & Lastdate
  ' ecowin column
   str2 = "=Sheet1!" & firstDyn & ":" & lastdyndate
  
  ' history date column
   str3 = "=Sheet1!" & FirstHistory & ":" & lasthistory
 
   ' check if chart exist
   If (Range("b1").Value = 1) Then
   
     ActiveSheet.ChartObjects("7990").Delete  'if exist,delete the old one
     Range("b1").Value = ""
     GoTo CHART                                ' creat new one
   
   Else
CHART:
   Set mychtobj = ActiveSheet.ChartObjects.Add _
        (Left:=400, Width:=400, Top:=75, Height:=250)
    mychtobj.CHART.ChartType = xlLine
    mychtobj.CHART.SetSourceData Source:=Sheets("Sheet1").Range("g13")
    mychtobj.CHART.SeriesCollection.NewSeries
    mychtobj.CHART.SeriesCollection.NewSeries
    mychtobj.CHART.SeriesCollection(1).XValues = str
    mychtobj.CHART.SeriesCollection(1).Values = str2
    mychtobj.CHART.SeriesCollection(2).Values = str3
    mychtobj.CHART.Location Where:=xlLocationAsObject, Name:="Sheet1"
   
   
 ' Set the title
    With mychtobj.CHART
        .HasTitle = False
        '.ChartTitle.Characters.Text = "us-dk"
        .HasLegend = False
        .Axes(xlCategory, xlPrimary).HasTitle = False
        .Axes(xlValue, xlPrimary).HasTitle = False
        .Parent.Name = "7990"
    End With
  Range("b1").Value = 1
  End If
    
mychtobj.CHART.Export "S:\MARKETS_INET\auto_upload\pdf_ubeskyttede_dk\toenderbank3000.pdf", "jpg"
 ThisWorkbook.Save
End Sub
--------------------------------------------------------------------
I don't think there is any problem in this code ,because when i run it alone, it works perfectly! But when i put it in the "Master.xls file". it won't be executed!??
here is the master.xls file ... I guess the problem is here!!!
---------------------------------------------------------------
Private Sub Workbook_Open()
Call timer
End Sub
'in a moduel
Sub timer()
   Application.OnTime now+timevalue("01:00:00"),"runall"
End Sub
' in the same module as timer
Sub RunAll()
Dim workbook1 As Workbook
Dim workbook2 As Workbook
Dim workbook3 As Workbook
Dim workbook4 As Workbook
Set workbook1 = Workbooks.Open("S:\MARKETS_INET\file1.xls)
workbook1.Activate
workbook1.save
Set workbook2 = Workbooks.Open("S:\MARKETS_INET\file2.xls)
workbook2.Activate
workbook2.save
Set workbook3 = Workbooks.Open("S:\MARKETS_INET\file3.xls)
workbook3.Activate
workbook3.save
Set workbook4 = Workbooks.Open("S:\MARKETS_INET\file4.xls)
workbook4.Activate
workbook4.save
call timer
End Sub
------------------------------------------------------------------
as I can see , all 4 files are open and executed one by one, but only file1 got updated, file 2-4 not. Even I change the order ,I put file1.xls in the last , still only file1.xls got updated,not the other 3 ...
I reall don't know why...And another minor thing is that Although I set 1 hour,(ontime now+timevalue("01:00:00")) .still it runs many times per hour.....
but this is ok..as long as all files get updated!
 Looking forward to your advice!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.