-
Oct 19th, 2020, 04:14 PM
#1
Thread Starter
New Member
Issue with password window
I have an issue. My code opens protected workbook in background - and it works fine, no issue, but when workbook is already open by other user, password window pops up - how to change that so user won't be able to see that password window? I add on error goto errhandler which contains that workbook is already open - it works fine when workbook is not protected, but with protected one this password window pops up.
Long story short:
when app opens a password protected workbook code works fine, but when app opens a password protected workbook that another user has open, it asks for the password?
Thank You in advance
Code:
on error goto errhan
Workbooks.Open Filename:= "C:\johndoe.xls", Password:="Password"
exit sub
errhan
messagebox.show("File is already open")
Any suggestions?
-
Oct 19th, 2020, 04:17 PM
#2
Re: Issue with password window
I've modified your post to include [code][/code] BB tags. In the future, please use them as it keeps your code formatted. I have a link on how to use the code formatting tags in my signature.
Also, on error goto is legacy syntax. Could you verify the specific language you're using (VB6, VBA for Excel, VB.NET, etc.)?
-
Oct 19th, 2020, 06:44 PM
#3
Re: Issue with password window
Originally Posted by dday9
Also, on error goto is legacy syntax. Could you verify the specific language you're using (VB6, VBA for Excel, VB.NET, etc.)?
Definitely not VB.NET, as Workbooks.Open has no parentheses. Almost certainly VBA, given that Workbooks is unqualified.
-
Oct 20th, 2020, 12:36 AM
#4
Thread Starter
New Member
Re: Issue with password window
I'm using VB.Net with Imports Excel = Microsoft.Office.Interop.Excel
Code:
Dim Epath As String = "C:\Users\Bartek\Desktop\New folder\data.xlsx"
Dim excel As Microsoft.Office.Interop.Excel.Application
excel = New Microsoft.Office.Interop.Excel.Application
Dim wBook As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim lr As Long, excelRow As Long
On Error GoTo APPERR
excel.Visible = False
excel.UserControl = False
wBook = excel.Workbooks.Open(Epath, Password:="Banik123", UpdateLinks:=False)
ws = excel.ActiveSheet
lr = ws.Range("A" & ws.Rows.Count).End(XlDirection.xlUp).Row + 1
excelRow = lr
If wBook.ReadOnly = True Then
MessageBox.Show("Data base is busy, please try again later")
wBook.Close()
releaseObject(excel)
releaseObject(wBook)
releaseObject(ws)
Exit Sub
End If
-
Oct 20th, 2020, 04:05 AM
#5
Re: Issue with password window
Originally Posted by ave470
I'm using VB.Net
And yet the code in post #4 is quite different to the code in post #1. If you want help with code then it's a good idea to post the code you want help with. Mind you, MessageBox.Show is specifically VB.NET so that original code would not work anywhere.
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
|