Results 1 to 3 of 3

Thread: Do While Loop For xlApp Declaration

  1. #1
    Herry Markowitz's Avatar
    Herry Markowitz is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 4.0
    Join Date
    Oct 2015
    Posts
    38
    Reputation
    20

    Do While Loop For xlApp Declaration

    I am wating 10 seconds before xlApp declaration because C:\Book1.xlsx is a very big file and takes long time to open.
    Code:
    Process.Start("C:\Book1.xlsx")
    Threading.Thread.Sleep(10000)
    Dim xlApp As Excel.Application = Nothing
    xlApp = CType(GetObject(Nothing, "Excel.Application"), Excel.Application)

    I want to replace above code like below code.
    Below code need to be repaired.
    Code:
    Process.Start("C:\Book1.xlsx")
    Do While SOMETHING
       Application.DoEvents()
    Loop
    Dim xlApp As Excel.Application = Nothing
    xlApp = CType(GetObject(Nothing, "Excel.Application"), Excel.Application)

    I am VBA expert.
    I am trying to be vb.net expert.

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,085
    Reputation
    2803
    Why not do it all with automation? Create an instance of Excel.Application and use its Workbooks.Open method.
    How to format posts with code blocks etc - present the problem/post properly

    Visual Studio Community 2017

  3. #3
    Herry Markowitz's Avatar
    Herry Markowitz is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 4.0
    Join Date
    Oct 2015
    Posts
    38
    Reputation
    20
    Because I want to open excel file in Safe Mode.

    Code:
    Process.Start("Excel.exe", "/safemode ""C:\Book1.xlsx""")
    I am VBA expert.
    I am trying to be vb.net expert.

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
  •