Question How to hide excel opening

mohideen_km

New member
Joined
Jul 25, 2008
Messages
2
Programming Experience
Beginner
Hi all,

I am new to VB.net,
I have created one coding for opening excel file and reading the content in it and finally writing to one txt file.
For that i am opening excel file through coding.
But what happening is, excel is opening and closing .I can see the excel opening and closing.
I want hide viewing for opening of excel file from user.User don't need the see
the excel opening and closing.User will specify the just file name.

I tried some visible false for excel.But it doesn't work.
Please can any body help me to solve this problem

Expecting Reply,
Thanks
Abdul
 
Depends how you launch Excel. Here's some code for loading processes I pulled out from my app I've got open right now:

VB.NET:
   Dim info As New ProcessStartInfo
 Dim p As New Process
        info.FileName = "C:\DSGameMaker/Temp/source/gfx/PAGfx.exe"
        info.WorkingDirectory = "C:\DSGameMaker/Temp/source/gfx"
        info.WindowStyle = ProcessWindowStyle.Hidden
        p.StartInfo = info
        p.Start()
        p.WaitForExit()

In specific, this line:

VB.NET:
 info.WindowStyle = ProcessWindowStyle.Hidden
 
How to hide Excel Opening

Hi all,

I'm using the following code to open the Excel File in VB for Reading the values:

xlBook = GetObject(Root.ToString & "\" & Filename.ToString)

(OR)

xlwbook = xl.Workbooks.Open(Root.ToString & "\" & Filename.ToString)

While running this code, the Excel files are opening in a new window and closing automatically.

I want to hide the opening and closing of that Excel Files.


I tried some visible false for excel.But it doesn't work.

Please can any body help me to solve this problem


Expecting Reply

Thanks
Abdul
 
Here's the function I use. It seems to work on my system.

VB.NET:
Public Function OpenExcelFile(ByVal xlsPath As String, Optional ByVal IsVisible As Boolean = True) As Boolean

        Try
            'initialize application
            xlsApp = New Microsoft.Office.Interop.Excel.Application

            'open workbook
            xlsWrkbk = xlsApp.Workbooks.Open(xlsPath)

            'turn off alers
            xlsApp.DisplayAlerts = False

            'check for hide
            If IsVisible = False Then
                xlsApp.Visible = False
            End If

            'set return value
            OpenExcelFile = True
        Catch ex As Exception

            'set return value
            OpenExcelFile = False

        End Try

    End Function  'opens the indicated excel file
 
Back
Top