ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   How to open file in the background. It is possible? (https://www.excelbanter.com/new-users-excel/28617-how-open-file-background-possible.html)

Andrzej

How to open file in the background. It is possible?
 

I would like to open file, but I do not want to people saw this.

I have a code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim szukana As Range
Dim Cecha As String
Dim bk As Workbook
Dim sh As Worksheet
Dim sh1 As Worksheet

If Not Application.Intersect(Columns("A:A"), Target) _
Is Nothing Then
Cecha = Target.Value

If Cecha = "" Then Exit Sub
On Error Resume Next
Set bk = Workbooks(p1.xls)
On Error GoTo 0
If bk Is Nothing Then
Set bk = Workbooks.Open(Filename:="H:\....p1.xls")
End If

Set sh1 = bk.Worksheets(bk.Worksheets.Count)
For Each sh In bk.Worksheets
Set szukana = sh.Cells.Find(What:=Cecha, _
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False)
If szukana Is Nothing Then
If sh.Name = sh1.Name Then
MsgBox "Sorry, but " & Cecha & " was not found"
ActiveWorkbook.Close
Target.Value = ""

End If
Else
bk.Activate
sh.Activate
szukana.Activate
MsgBox "Szukana cecha " & Cecha & " was found"
ActiveWorkbook.Close

End If
Next sh

End If

End Sub




Chip Pearson

Use the ScreenUpdating property. E.g.,

Application.ScreenUpdating = False
' your code here
Application.ScreenUpdating = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Andrzej" wrote in message
...

I would like to open file, but I do not want to people saw
this.

I have a code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim szukana As Range
Dim Cecha As String
Dim bk As Workbook
Dim sh As Worksheet
Dim sh1 As Worksheet

If Not Application.Intersect(Columns("A:A"), Target) _
Is Nothing Then
Cecha = Target.Value

If Cecha = "" Then Exit Sub
On Error Resume Next
Set bk = Workbooks(p1.xls)
On Error GoTo 0
If bk Is Nothing Then
Set bk = Workbooks.Open(Filename:="H:\....p1.xls")
End If

Set sh1 = bk.Worksheets(bk.Worksheets.Count)
For Each sh In bk.Worksheets
Set szukana = sh.Cells.Find(What:=Cecha, _
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False)
If szukana Is Nothing Then
If sh.Name = sh1.Name Then
MsgBox "Sorry, but " & Cecha & " was not found"
ActiveWorkbook.Close
Target.Value = ""

End If
Else
bk.Activate
sh.Activate
szukana.Activate
MsgBox "Szukana cecha " & Cecha & " was found"
ActiveWorkbook.Close

End If
Next sh

End If

End Sub







All times are GMT +1. The time now is 06:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com