|
-
Feb 23rd, 2005, 06:57 PM
#1
Thread Starter
Hyperactive Member
Excel in VB
I have a vb 6 program that is writing to an excel sheet on the network. The users have access to this file as well. Some time when the users leave at night they leave the file open and the program cannot write to it. and hangs in the scheduler. Is there a way of checking if the file is already open and who has it open .
-
Feb 23rd, 2005, 06:58 PM
#2
Re: Excel in VB
you could shut down the pc, which closes everything off.
-
Feb 23rd, 2005, 07:00 PM
#3
Re: Excel in VB
Here is some code to enumerate the Excel users on a workbook. Should do the trick.
VB Code:
Private Sub Workbook_Open()
users = ActiveWorkbook.UserStatus
With Workbooks.Add.Sheets(1)
For Row = 1 To UBound(users, 1)
.Cells(Row, 1) = users(Row, 1)
.Cells(Row, 2) = users(Row, 2)
Select Case users(Row, 3)
Case 1
.Cells(Row, 3).Value = "Exclusive"
Case 2
.Cells(Row, 3).Value = "Shared"
End Select
Next
End With
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 23rd, 2005, 07:02 PM
#4
Re: Excel in VB
 Originally Posted by dglienna
you could shut down the pc, which closes everything off.
Now why would you want to take the chance of corrupting the workbook with an unexpected shutdown/disconnection.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|