Flash display of chart

D

daniel chen

Somebody, Please.
Is it possible to write a macro that opens a workbook for a few seconds to
display a chart and then close it ?
Let's say on my 'C:\test\[Console.xls]Display'!B5 , specified value is 6
(for 6 seconds).
How do I modify the following macro that opens 'WorkbookA.xls' for 6
seconds.

Sub FlashB5sec()
Workbooks.Open Filename:="C:\test\WorkbookA.xls", UpdateLinks:=0
Sheets("Chart").Select
Range("M4:T22").Select
' Time lapsed 6 seconds specified in Cell B5 of
'C:\test\[Console.xls]Display'!B5
Workbooks("C:\test\WorkbookA.xls").Close SaveChanges:=False
End Sub

Or, any other alternative means will be greatly appreciated.
 
D

Dave Peterson

Take a look at:

Application.Wait
in VBA's help.

Option Explicit
Sub FlashB5sec()

Dim FlashWkbk As Workbook

Set FlashWkbk = Workbooks.Open _
(Filename:="C:\my documents\excel\book1.xls", UpdateLinks:=0)
' Sheets("Chart").Select
' Range("M4:T22").Select

Application.Wait Now + TimeSerial(0, 0, 6)

FlashWkbk.Close SaveChanges:=False

End Sub

PS. you don't give the whole drive/path when you use workbooks()

I used an object variable, but:

workbooks("workbookA.xls").close savechanges:=false

would be ok, too.

daniel said:
Somebody, Please.
Is it possible to write a macro that opens a workbook for a few seconds to
display a chart and then close it ?
Let's say on my 'C:\test\[Console.xls]Display'!B5 , specified value is 6
(for 6 seconds).
How do I modify the following macro that opens 'WorkbookA.xls' for 6
seconds.

Sub FlashB5sec()
Workbooks.Open Filename:="C:\test\WorkbookA.xls", UpdateLinks:=0
Sheets("Chart").Select
Range("M4:T22").Select
' Time lapsed 6 seconds specified in Cell B5 of
'C:\test\[Console.xls]Display'!B5
Workbooks("C:\test\WorkbookA.xls").Close SaveChanges:=False
End Sub

Or, any other alternative means will be greatly appreciated.
 
D

daniel chen

Hi, Dave, Thank you very much. I have a lot to learn.

Dave Peterson said:
Take a look at:

Application.Wait
in VBA's help.

Option Explicit
Sub FlashB5sec()

Dim FlashWkbk As Workbook

Set FlashWkbk = Workbooks.Open _
(Filename:="C:\my documents\excel\book1.xls", UpdateLinks:=0)
' Sheets("Chart").Select
' Range("M4:T22").Select

Application.Wait Now + TimeSerial(0, 0, 6)

FlashWkbk.Close SaveChanges:=False

End Sub

PS. you don't give the whole drive/path when you use workbooks()

I used an object variable, but:

workbooks("workbookA.xls").close savechanges:=false

would be ok, too.

daniel said:
Somebody, Please.
Is it possible to write a macro that opens a workbook for a few seconds to
display a chart and then close it ?
Let's say on my 'C:\test\[Console.xls]Display'!B5 , specified value is 6
(for 6 seconds).
How do I modify the following macro that opens 'WorkbookA.xls' for 6
seconds.

Sub FlashB5sec()
Workbooks.Open Filename:="C:\test\WorkbookA.xls", UpdateLinks:=0
Sheets("Chart").Select
Range("M4:T22").Select
' Time lapsed 6 seconds specified in Cell B5 of
'C:\test\[Console.xls]Display'!B5
Workbooks("C:\test\WorkbookA.xls").Close SaveChanges:=False
End Sub

Or, any other alternative means will be greatly appreciated.
 

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

Similar Threads


Top