none
Document Locks When Debugging vb.net Code RRS feed

  • Question

  • I feel I may have a parameter incorrectly set, but when I debug code for a Word add-in written vb.net, the document locks - I can't move around in the document to see what's happening lower down.  I don't have ScreenUpdating locked (I can see the screen move, I just can't scroll it myself) and I don't have any modal form open.

    I'm using VSTO version 15.3.2 and .net framework 4.7.03056.

    I can interact with the document when I write the same code in VBA but not vb.net.  Any ideas?  

    Tuesday, February 12, 2019 4:23 PM

Answers

  • Hi,

    Is it possible because the word document has been opened?You can use the following method to determine if the file is in use, true means it is in use, false is not used.

    Public Shared Function IsFileInUse(ByVal fileName As String) As Boolean
        Dim inUse As Boolean = True
        Dim fs As FileStream = Nothing
        Try
            fs = New FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None)
            inUse = False
        Catch
        Finally
            If fs IsNot Nothing Then fs.Close()
        End Try
        Return inUse
    End Function

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by FlyinBlind Tuesday, January 14, 2020 6:09 PM
    Friday, February 15, 2019 3:25 AM

All replies

  • Hello,

    It's impossible to assist without seeing your code.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, February 12, 2019 9:10 PM
    Moderator
  • Did you stop at breakpoint in Visual Studio? Try continuing the execution.
    Wednesday, February 13, 2019 7:15 AM
  • A laughable response.  I would rather you ignore my entreaty than post something so inane.  This question is about about the IDE.  Should I find and post the source code for that?



    Wednesday, February 13, 2019 2:47 PM
  • There is a breakpoint set but that's not the problem.  In VBA I can scroll through the document and manipulate the text WHILE VBA is executing and at a breakpoint.

    In VB.NET I can't interact with the document (scroll or change text).  I was wondering if there was a parameter there somewhere that dealt with this.  It's more an annoyance than anything,


    Wednesday, February 13, 2019 2:49 PM
  • Hi,

    Is it possible because the word document has been opened?You can use the following method to determine if the file is in use, true means it is in use, false is not used.

    Public Shared Function IsFileInUse(ByVal fileName As String) As Boolean
        Dim inUse As Boolean = True
        Dim fs As FileStream = Nothing
        Try
            fs = New FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None)
            inUse = False
        Catch
        Finally
            If fs IsNot Nothing Then fs.Close()
        End Try
        Return inUse
    End Function

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by FlyinBlind Tuesday, January 14, 2020 6:09 PM
    Friday, February 15, 2019 3:25 AM