Click here to Skip to main content
15,943,726 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I am working on a project where I need to open excel from one website and after that I need to save it. I am not saving this excel to my file system.

I run all the vba code and lastly I am saving this file. However saving is taking time and my excel code closes the file before it gets saved.

I need a code that can wait till the excel is being saved.

Can anyone guide me please?

What I have tried:

I have tried searching on web but I did not find any relative answer.....
Updated 24-Nov-22 5:08am
CHill60 22-Nov-22 11:56am    
Show the VBA code you are using to save the file. The only reason I can think of that your code is terminating before the save, is that it is throwing an error
Graeme_Grant 22-Nov-22 16:43pm    
Why not show a form to tell the user that you are busy saving changes?
CHill60 23-Nov-22 3:52am    
You are already attracting downvotes to this question - if you still need help then please post the code you are using to save the file and I will try to help. Otherwise, this question is likely to get deleted for being unclear or incomplete.
Keyur Raval 2022 24-Nov-22 0:18am    
Thank you for your comment.. sorry for being late. It is not throwing error and excel file is getting saved on local computer. However in title bar still it shows "Excel File Name. xlsx - Saving" when I close button it shows "Updating to server..."
I need a code that can see in the title bar until "Saving" turns to "Saved"

Currently I am using simple code to save workbook as mentioned below
CHill60 24-Nov-22 11:01am    
Firstly, if you are going to respond to a comment then use the "Reply" link next to it. I only spotted this by accident.
Next: Your question explicitly said "I am not saving this excel to my file system.
" and "my excel code closes the file before it gets saved." but now you are saying "excel file is getting saved on local computer" - so what is your problem?

1 solution

I've just re-read your comments and noticed
when I close button it shows "Updating to server..." I need a code that can see in the title bar until "Saving" turns to "Saved"
This implies that it is not your code that is a problem but that YOU are closing the file before the save is complete. You should let your code do that e.g. see this simple demo
Option Explicit

Public Sub Demo()

    Dim objWorkBook As Excel.Workbook
    Set objWorkBook = ThisWorkbook


End Sub
Share this answer
Keyur Raval 2022 25-Nov-22 0:06am    
Hello Sir,

Thank you for your guidance for Reply comment. I will take care of that from next time..

Here my problems is that I am opening this Excel file is from web - and not saving to my local file system.

After that I run vbscript on this file. I use below code to get the particular instance of Excel Workbook:

Set obj = GetObject(,"Excel.Application")

obj.DisplayAlerts = True

Dim wb, pDestinationFile
For Each wb In obj.Workbooks
If InStr(wb.Name, DestFileName) > 0 Then
Set pDestinationFile = wb
End if

.....My code to procee

'after that I am saving and closing the excel file as you mentioned in the code.


'' the Excel status bar is showing "Saving.. " message and when it completes the "Saving.." message starts on Excel Title Bar.. If I wait then after sometime it shows as "Saved".. but if I in between closing the excel then it shows "Uploading to Server" dialogue box. If I close this dialogue box then it shows a message box "changes saved locally will try to update your changes when you open excel next time"..

I want to wait until title bar "Saving... " turns to "Saved".. and want code for that...
CHill60 25-Nov-22 4:30am    
Whether you are saving the file in VBScript or VBA just wait until the save has completed. You are breaking the process by closing the file manually.
There is a sample access-the-title-of-a-window-using-vbscript/20398390#20398390[^] of how to get the titles of running processes
Keyur Raval 2022 26-Nov-22 4:53am    
Hello sir,
I tried the way you suggested... But it does not capture "Saving.." Or "Saved" message.. Also generally I do not closing the file manually... I just mentioned what happens when I close the file manually.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900