abenitez77
Board Regular
- Joined
- Dec 30, 2004
- Messages
- 149
I run some code looping thru the tabs in a spreadsheet and I get a "printer setup" popup. It pops up every 10 minutes or so. How can I avoid this msg?
This is my code:
This is my code:
Code:
Set connection2 = CreateObject("ADODB.Connection")
ConnectionString = GetConnectionString
connection2.Open ConnectionString
'Disable messages from poping up, causing the code to pause.
Application.AskToUpdateLinks = False
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.ActivePrinter = "Microsoft XPS Document Writer on Ne01:"
ActiveWindow.View = xlNormalView
'Open the Spreadsheet
On Error GoTo SkipRec_Error
Set wbIn = Workbooks.Open(iPath, UpdateLinks:=0, ReadOnly:=True, CorruptLoad:=xlRepairFile)
'Set New WorkBook Name
NewWkBk = ActiveWorkbook.Name
OpenXLFilePath = iPath
' ------------------------------ Remove Passwords from Each Tab ------------------------------------
If ActiveSheet.ProtectContents = True Then
If PasswordBreaker = False Then
' ----------- Password Failed, Copy the spreadsheet to a blank spreadsheet for processing ----------
Call CopyProtectedDataToNewSheet
End If
End If
' ----------------------------------- Get Tab and Worksheet info ---------------------------------
currentSheet = ActiveSheet.Index
sheetcount = ActiveWorkbook.Sheets.Count
' Get the Path and File name of the spreadsheet
xFilePath = iPath
' Get the File name (ONLY) of the spreadsheet
xFileName = ActiveWorkbook.Name
xFilePath = Replace(xFilePath, "'", "''")
xFileName = Replace(xFileName, "'", "''")
'Reset Flag
ProcessedXLS = False
HdrSkipRec = False 'If skip Header while import then SET TRUE else false
DtlSkipRec = False 'If skip Detail while import then SET TRUE else false
Reason = ""
Result = False
' ----------------------------------- Loop thru each tab in the Spreadsheet -------------------------------
For counter = 1 To sheetcount
Sheets(counter).Activate
xSheetName = Sheets(counter).Name
Sheets(counter).Activate ' Set current Tab Active
Sheets(counter).Visible = True
Sheets(counter).Columns.EntireColumn.AutoFit ' *********** Added this line to expand width to fit dates/numbers/text/etc... ***********
ActiveWindow.View = xlNormalView
'Status Bar updates...
Application.AskToUpdateLinks = False: Application.EnableEvents = False: Application.ScreenUpdating = False
Application.DisplayAlerts = False: oldStatusBar = Application.DisplayStatusBar: Application.DisplayStatusBar = True
Application.StatusBar = "Working on Record " & Str(xi) & " of " & Str(totx) & " ( " & xSheetName & " ) Tab " & Str(counter) & " of " & Str(sheetcount)
' Checking All SheetNames.... Deals are found in names not with DEAL.
HdrID = currid
Set iRange = Nothing
Set ResultRange = Nothing
MySearch = "Vendor Information"
Set iRange = Sheets(xSheetName).Range("A1:P2000")
Set ResultRange = FindAll(iRange, MySearch)
'Sheet name is not constant so check Is Deal Sheet or not?
If Not (ResultRange Is Nothing) Then
'Show all columns
Columns("A:CZ").EntireColumn.Hidden = False
'HdrSkipRec, DtlSkipRec and Reason are reference parameters.
Call GetHeaderData(xSheetName, xFilePath, HdrID, ProcessedXLS, HdrSkipRec, DtlSkipRec, Reason)
ElseIf IsItemDetailsSheet(xSheetName) = True Then
'import Item details sheet
' Call GetItemDetailsData(xSheetName, HdrID, DtlSkipRec, Reason, xFileName, xFilePath)
Else
If Not ProcessedXLS Then ProcessedXLS = False
End If
NextTab:
Next counter