LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Excel Calculation is faster when visible than when Visible=False?


I have an application that makes use of excel Interop

Im using Microsoft Excel Object Library 10

The application does the following:
€¢ Loads an existing analysis spreadsheet
€¢ Sets Calculation mode to Manual (to prepare for efficient data import)
€¢ Clears the first worksheet (of previous input data)
€¢ Imports the text file into the first worksheet
€¢ Set Calculation mode back to automatic
€¢ Parses a field cells on a results Worksheet

I noticed while testing the application that the cells appear to
(re)calculate much faster when the objApp.Visible = true. (Improving
calculation speed from several minutes to ~ 25 seconds) This doesnt make
sense to me. My only thought is that excel is throwing up a prompt when my
spreadsheet is running invisibly and that this prompt eventually times out
allowing my method to eventually complete. I have already set DisplayAlerts
to false. The Analysis spreadsheet does not contain any macros so I wouldnt
have expected this to be a privilege issue.

I prefer never to display the spreadsheet.

If anyone has any suggestions I would greatly appreciate them

Thanks,

Jeff
€˜############################################
€˜code that opens the spreadsheet
objApp = New Excel.Application
objApp.DisplayAlerts = False
objApp.UserControl = False
objApp.Visible = False €˜True

objBooks = objApp.Workbooks

€˜objBooks.Open(FileName, UpdateLinks, ReadOnly, Format, Password,
WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable,
Notify, Converter, AddToMRU)

objBook = objBooks.Open(FilePath, 0, True, 5, String.Empty, String.Empty,
True, Excel.XlPlatform.xlWindows, ",", True, False, 0, True)
€˜##########################################

€˜public method that imports the text file
Public Sub importDataFromFile(ByVal FilePath As String)
Me.CalculationMode = Excel.XlCalculation.xlCalculationManual
'Import CSV file into data worksheet
importDataFromFile(FilePath, Sheets.Data)
Me.CalculationMode = Excel.XlCalculation.xlCalculationAutomatic
m_Calculating = False

End Sub

€˜##############################################

€˜ method that imports the text file into the WorkSheet
Protected Sub ImportDataFromFile(ByVal FilePath As String, ByVal
WorkSheetIndex As Integer)
Dim dataSheet As Excel._Worksheet =
CType(Me.objSheets(WorkSheetIndex), Excel._Worksheet) '
dataSheet.Activate()
ClearWorksheet(dataSheet) 'Must clear otherwise old data will just
be shifted to the right of new data


dataSheet.Range("A1").Select()
With dataSheet.QueryTables.Add(Connection:=String.Forma t("TEXT;{0}",
FilePath), _
Destination:=dataSheet.Range("A1"))
.Name = "Test_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = Excel.XlTextParsingType.xlDelimited
.TextFileTextQualifier =
Excel.XlTextQualifier.xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileTrailingMinusNumbers = True
.Refresh(BackgroundQuery:=False)
End With

End Sub


 
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
How to make a few rows visible and hide some others ... faster tskogstrom Excel Programming 2 October 5th 07 07:39 PM
excel 2007 problem, activewindow.visible = false does not work [email protected] Excel Programming 1 May 1st 07 09:20 AM
Application.Visible = False SimonB Excel Discussion (Misc queries) 1 October 15th 06 01:10 PM
Worksheet has to set to visible as it is not visible after saving and closing Excel by VB. Oscar Excel Programming 6 June 21st 05 10:39 PM
Visible=false bcnu Excel Programming 2 December 29th 04 02:07 PM


All times are GMT +1. The time now is 01:55 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"