Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Pop up Windows Question

Dear Expert,

I have written some macros.
Sometimes, it has "save" function.
Then it would pop up a MSG windows asking you "Do you want to save changes
you made to 'MMDEALS.XLS'?

Macro will stop until you click yes or now.

Can VB scripts be written to answer "Yes" automatically ?

Also, If I use "save as", there is a pop up msgbox too.
A file named 'C:\marco\Income_new.xls' already exists in this location. Do
you want to replace it?

Can VB scripts be written to answer "Yes" automatically ?

Thanks so much
Elton
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Pop up Windows Question

Please refer..Cant we take off the Msgbox and Save by default...

Another way is to Save the file in all cases of vbYes/vbNo/vbCancel

OR

You can also try SENDKEYS() . Refer the below link
http://www.developerfusion.com/code/...automatically/

Please try and let us know

If this post helps click Yes
---------------
Jacob Skaria


"Elton Law" wrote:

Dear Expert,

I have written some macros.
Sometimes, it has "save" function.
Then it would pop up a MSG windows asking you "Do you want to save changes
you made to 'MMDEALS.XLS'?

Macro will stop until you click yes or now.

Can VB scripts be written to answer "Yes" automatically ?

Also, If I use "save as", there is a pop up msgbox too.
A file named 'C:\marco\Income_new.xls' already exists in this location. Do
you want to replace it?

Can VB scripts be written to answer "Yes" automatically ?

Thanks so much
Elton

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Pop up Windows Question

Just tell excel how to close the workbook.

Dim wkbk as workbook
set wkbk = .....
.....
wkbk.close savechanges:=true 'or false to discard the changes.

Elton Law wrote:

Dear Expert,

I have written some macros.
Sometimes, it has "save" function.
Then it would pop up a MSG windows asking you "Do you want to save changes
you made to 'MMDEALS.XLS'?

Macro will stop until you click yes or now.

Can VB scripts be written to answer "Yes" automatically ?

Also, If I use "save as", there is a pop up msgbox too.
A file named 'C:\marco\Income_new.xls' already exists in this location. Do
you want to replace it?

Can VB scripts be written to answer "Yes" automatically ?

Thanks so much
Elton


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Pop up Windows Question

Hi Dave,
Please apologize if I am stupid.
I try to copy your wordings and test.
I does not work
It stops at "wkbk.Close Savechanges:=True"
Is it due to my version ?
Mine is Excel 2000 only.
Thanks
Elton

Sub Macro1()

Dim wkbk As Workbook
Application.Goto Reference:="R1C1"
ActiveCell.FormulaR1C1 = "=NOW()"
ActiveCell.Select
Selection.Copy
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

ActiveWorkbook.SaveAs Filename:="H:\ActivateWindows_Test",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

wkbk.Close Savechanges:=True

End Sub


"Dave Peterson" wrote:

Just tell excel how to close the workbook.

Dim wkbk as workbook
set wkbk = .....
.....
wkbk.close savechanges:=true 'or false to discard the changes.

Elton Law wrote:

Dear Expert,

I have written some macros.
Sometimes, it has "save" function.
Then it would pop up a MSG windows asking you "Do you want to save changes
you made to 'MMDEALS.XLS'?

Macro will stop until you click yes or now.

Can VB scripts be written to answer "Yes" automatically ?

Also, If I use "save as", there is a pop up msgbox too.
A file named 'C:\marco\Income_new.xls' already exists in this location. Do
you want to replace it?

Can VB scripts be written to answer "Yes" automatically ?

Thanks so much
Elton


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Pop up Windows Question

If you want Excel to always SAVE, why ask in the first place?!?

But, if you really want the MsgBox, you could do something like:

Answer = MsgBox("Save?",vbYesNo,"Save")
Answer = vbYes

....continue saving here...




Elton Law wrote:
Dear Expert,

I have written some macros.
Sometimes, it has "save" function.
Then it would pop up a MSG windows asking you "Do you want to save
changes you made to 'MMDEALS.XLS'?

Macro will stop until you click yes or now.

Can VB scripts be written to answer "Yes" automatically ?

Also, If I use "save as", there is a pop up msgbox too.
A file named 'C:\marco\Income_new.xls' already exists in this
location. Do you want to replace it?

Can VB scripts be written to answer "Yes" automatically ?

Thanks so much
Elton





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Pop up Windows Question

Try this code

Dim wkbk As Workbook
Application.Goto Reference:="R1C1"
ActiveCell.FormulaR1C1 = "=NOW()"
ActiveCell.Select
Selection.Copy
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="H:\ActivateWindows_Test.xls"
wkbk.Close Savechanges:=True
Application.DisplayAlerts = True
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Pop up Windows Question

Please note that I have only modified the last part of your code.....

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Try this code

Dim wkbk As Workbook
Application.Goto Reference:="R1C1"
ActiveCell.FormulaR1C1 = "=NOW()"
ActiveCell.Select
Selection.Copy
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="H:\ActivateWindows_Test.xls"
wkbk.Close Savechanges:=True
Application.DisplayAlerts = True
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Pop up Windows Question

Hi Super Jacob,
Really appreciate your help today ....

I try run as what you say ....

It stops at here - "wkbk.Close Savechanges:=True"
Pop up a msgbox saying Run-time error '91'
Object variable or with block variable not set

Then what should I do ? Thanks
Elton

(quote)
Sub Marco2()
Dim wkbk As Workbook

Windows("CXLFX.xls").Activate
Application.Goto Reference:="R1C1"
ActiveCell.FormulaR1C1 = "=NOW()"
ActiveCell.Select
Selection.Copy
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="H:\ActivateWindows_Test111.xls"
wkbk.Close Savechanges:=True
Application.DisplayAlerts = True
End Sub
(End of Quote)


"Jacob Skaria" wrote:

Try this code

Dim wkbk As Workbook
Application.Goto Reference:="R1C1"
ActiveCell.FormulaR1C1 = "=NOW()"
ActiveCell.Select
Selection.Copy
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="H:\ActivateWindows_Test.xls"
wkbk.Close Savechanges:=True
Application.DisplayAlerts = True
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Pop up Windows Question

Oops....Replace error line with...As I mentioned earlier I havent dont much
changes to the code....

ActiveWorkbook.Close Savechanges:=True

--
If this post helps click Yes
---------------
Jacob Skaria


"Elton Law" wrote:

Hi Super Jacob,
Really appreciate your help today ....

I try run as what you say ....

It stops at here - "wkbk.Close Savechanges:=True"
Pop up a msgbox saying Run-time error '91'
Object variable or with block variable not set

Then what should I do ? Thanks
Elton

(quote)
Sub Marco2()
Dim wkbk As Workbook

Windows("CXLFX.xls").Activate
Application.Goto Reference:="R1C1"
ActiveCell.FormulaR1C1 = "=NOW()"
ActiveCell.Select
Selection.Copy
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="H:\ActivateWindows_Test111.xls"
wkbk.Close Savechanges:=True
Application.DisplayAlerts = True
End Sub
(End of Quote)


"Jacob Skaria" wrote:

Try this code

Dim wkbk As Workbook
Application.Goto Reference:="R1C1"
ActiveCell.FormulaR1C1 = "=NOW()"
ActiveCell.Select
Selection.Copy
ActiveCell.Offset(2, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="H:\ActivateWindows_Test.xls"
wkbk.Close Savechanges:=True
Application.DisplayAlerts = True
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro switch between windows question punter Excel Discussion (Misc queries) 3 June 21st 06 06:11 PM
XP windows Registry Question saziz Excel Discussion (Misc queries) 1 June 11th 06 02:25 AM
windows xp file name convertion question Sceptor Excel Discussion (Misc queries) 4 March 26th 05 05:58 PM
Windows Explorer Question Raul Excel Programming 4 January 12th 05 01:01 PM
AddressOf / Windows API question Amos Excel Programming 1 February 25th 04 05:18 PM


All times are GMT +1. The time now is 09:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"