View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Desmond Desmond is offline
external usenet poster
 
Posts: 28
Default How to open a workbook?

The following code says syntax error:

Workbooks.Open ("C:\Documents and Settings\Mei FENG\My Documents\Work
Related Excel\2005q4.xls", False)

"Andrew Taylor" wrote:

The optional second parameter of Workbooks.Open is "UpdateLinks", so
Workbooks.Open (filename, False)
will open it without prompting and without updating. Change False to
True
if you do want to update links.


Desmond wrote:
i intend to check if 2005q4 is open, if not, then open it.

Problems with the following code: it stops at the for loop; when 2005q4
opens, it still prompts a message asking me if i want to update links,
displayalerts set to false does not work in this kind of prompted message?

i = Workbooks.Count
For Each wk In Workbooks(i)
If wk.Name < "2005q4" Then
On Error Resume Next
Application.DisplayAlerts = False
Workbooks.Open ("C:\Documents and Settings\Mei FENG\My
Documents\Work Related Excel\2005q4.xls")
On Error GoTo 0
End If
Next



"Desmond" wrote:

Figured it out:

Workbooks.Open ("C:\Documents and Settings\ZZZ\My
Documents\WorkRelatedExcel\2005q4.xls")


"Desmond" wrote:

I need to check if a workbook, named 2005q4, is open, and if not, open it
and filter the data, copy them to a worksheet in a different workbook (which
is open), and create a PivotTable. I have created my code assuming 2005q4 is
open, (may not be active). How can i open 2005q4 if it is not open, suppose
it is in the following path:

C:\Documents and Settings\ZZZ\My Documents\WorkRelatedExcel\[2005q4.xls]

Thank you in advance!