Michael Zh.

Hi Groups:
I used Application.ScreenUpdating=false; in my code twice, one is working, but another one is not working.
The following is my code:

This one is working:
private void updateProjectList_Click(object sender, EventArgs e)
{
updateProjectsInHT();
setProjectToTable();
}

public void updateProjectsInHT()
{
Application.ScreenUpdating = false;

Excel.Workbook wb = (Excel.Workbook)Application.Workbooks.Open("D:\\CVS_HOME\\L10N1H05\\Quality Management\\Team Member Effort Data\\FY07\\ProjectList.xls", false, true, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
Excel.Worksheet ws1;
Excel.Range range1, range2;
...
}

This one is not working:
private void initiateProg_Click(object sender, EventArgs e)
{
...
Application.ScreenUpdating = false;

for (int nameIndex = 0; nameIndex < nameList.Count; nameIndex++)
{
wb1 = (Excel.Workbook)this.Application.Workbooks.Open("D:\\CVS_HOME\\L10N1H05\\Quality Management\\Team Member Effort Data\\FY07\\EffortTracking_" + nameList[nameIndex].ToString() + ".xls", false, true, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
...
}

I've verified that although I set the it to false, it's value is still 'true' after Application.Workbooks.Open operation...
Why
Why the first one is working

Thanks



Re: Visual Studio Tools for Office Fail to do ScreenUpdating=false

Ji Zhou – MSFT

Hi Yilei,

Have you resolved this problem yet I write a code snippet, which try to reproduce your issue. But both ScreenUpating property work fine in my side. Codes are like the following

Code Snippet

private void button1_Click(object sender, EventArgs e)

{

bool temp = Application.ScreenUpdating;

Application.ScreenUpdating = false;

for (int i = 1; i < 1000; i++)

{

((Excel.Range)this.Cells[i, 1]).Value2 = "test1";

}

this.Application.Workbooks.Open(@"C:\test.xlsx", missing, missing, missing, missing,

missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);

Application.ScreenUpdating = temp;

}

private void button2_Click(object sender, EventArgs e)

{

bool temp = Application.ScreenUpdating;

Application.ScreenUpdating = false;

for (int i = 1; i < 1000; i++)

{

((Excel.Range)this.Cells[i, 2]).Value2 = "test2";

}

this.Application.Workbooks.Open(@"C:\test2.xlsx", missing, missing, missing, missing,

missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);

Application.ScreenUpdating = temp;

}

Is there other Excel Add-in run on your machine My guess is that maybe other Add-in or program will modify the Application.ScreenUpdating property. The best practice to use Application.Screen is to store this property in another variable every time before you change it. After the long performance, you can modify it back to the temp value.

Reason to do like this is, maybe there’s not only one programs or add-ins are running in the same time. But the Application.ScreenUpdating property is shared among them. So we should make sure they will not affect each other through this means.

If this still cannot help, please feel free to let me know J

Thanks

Ji






Re: Visual Studio Tools for Office Fail to do ScreenUpdating=false

Michael Zh.

Hi Ji,

The problem is still there.

In order to check the status of Application.ScreenUpdating property, I use two MessageBox.Show to print it's value. One is before the method, another is just after the method.

The first one shows 'false', but the second shows 'true'.

I didn't so anything, just:

wb1 = Openfile("D:\\CVS_HOME\\L10N1H05\\Quality Management\\Team Member Effort Data\\FY07\\EffortTracking_" + nameList[nameIndex].ToString() + ".xls");

Strange...

Thanks for your reply.






Re: Visual Studio Tools for Office Fail to do ScreenUpdating=false

Michael Zh.

Hi Ji,

The problem is still there.

In order to check the status of Application.ScreenUpdating property, I use two MessageBox.Show to print it's value. One is before the method, another is just after the method.

The first one shows 'false', but the second shows 'true'.

I didn't so anything, just:

wb1 = Openfile("D:\\CVS_HOME\\L10N1H05\\Quality Management\\Team Member Effort Data\\FY07\\EffortTracking_" + nameList[nameIndex].ToString() + ".xls");

Strange...

Thanks for your reply.






Re: Visual Studio Tools for Office Fail to do ScreenUpdating=false

Ji Zhou – MSFT

Hi Yilei,

Could this strange issue potentially result from the specific document If we create an excel file in C:\, and use wb1 = Openfile(@“C:\test.xls”), does the problem still exist

And it is difficult to find the reason when not seeing the whole codes. If you like, you can minimize your project to reproduce the issue and send to me. MSN: colbertzhou@hotmail.com

Thanks

Ji






Re: Visual Studio Tools for Office Fail to do ScreenUpdating=false

Michael Zh.

Hi Ji,

Recently I don't have time to do detailed investigation on that problem, but I think your assumption is right.

I have some external links in the excel file which causes Excel poping out a Window and asks me if I should update those links, I think that may be the root cause.

Recently I met another issue:

Please see the following link if you could help, thanks.

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2117284&SiteID=1&mode=1

Michael