+ Reply to Thread
Results 1 to 2 of 2

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

  1. #1
    Andrzej
    Guest

    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





  2. #2
    Robin Hammond
    Guest

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

    Application.ScreenUpdating = FALSE should do it. Set it back to true after
    you have closed the workbook.

    Robin Hammond
    www.enhanceddatasystems.com

    "Andrzej" <a22p@wp.pl> wrote in message
    news:%23f$BubiZFHA.3184@TK2MSFTNGP15.phx.gbl...
    >
    > 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
    >
    >
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1