• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Save another workbook in the background

inddon

Member
Hello There,

I have 2 workbooks. I would like to have the following:
Workbook 1 is the data stored
Workbook 2 is where the User enters the data. This gets saved in Workbook 1.

When the User clicks the button Save:
1. In the background, it should save the workbook 1, without any prompts or message

I have the below code which saves the workbook 1, but it first displays the workbook 1 and then saves it:

Code:
option explicit

Public MstWB As Workbook
Public MstDBFileName As String

Sub FileOpen()
  Set MstWB = Workbooks.Open(Filename:=MstDBFileName, ReadOnly:=False, Notify:=False)
End Sub

Sub SaveMasterWorkbook ()
  MstWB.Save
End Sub


Could you please advise how the above can be achieved?

Thanks & regards,
Don
 
Hi,
try
Code:
Sub FileOpen()
Application.ScreenUpdating = False
  Set MstWB = Workbooks.Open(Filename:=MstDBFileName, ReadOnly:=False, Notify:=False)
  ActiveWindow.Visible = False
  ThisWorkbook.Activate
Application.ScreenUpdating = True
End Sub
 
Hi,
try
Code:
Sub FileOpen()
Application.ScreenUpdating = False
  Set MstWB = Workbooks.Open(Filename:=MstDBFileName, ReadOnly:=False, Notify:=False)
  ActiveWindow.Visible = False
  ThisWorkbook.Activate
Application.ScreenUpdating = True
End Sub


Hi Belleke,

Thank you for your reply and the code.

MstWB = Workbook 1

I am working on Workbook 2. The below Sub is in this workbook.

When the below Sub gets fired it saves the MstWB. However, when doing so it displays the Workbook (i.e. MstWB), and then saves.

I am looking for the following. When the Sub SaveMasterWorkbook fires it should silently save MstWB in the background without displaying the workbook or any messages


Code:
Sub SaveMasterWorkbook ()
  MstWB.Save
EndSub


Thanks again & regards,
Don
 
???? This.
Code:
Sub SaveMasterWorkbook()
Application.DisplayAlerts = False
  MstWB.Save
Application.DisplayAlerts = True
End Sub
 
Back
Top