Hi,
I succesfully use a VBA-program for starting up other applications,. i.e. other spreadsheets.
Example:
This works beautifully.Sub ShellProg ()
Dim ResStart As Variant
Dim strPath, strFile, strShell, strName As String
strPath = Worksheets("Standards").Cells(2, 2).Value
strFile = Worksheets("Standards").Cells(9, 2).Value
strShell = strPath + " " + strFile
strName = "UserSheet1.xls"
ResStart = Shell(strShell, 1)
strPath = Worksheets("Standards").Cells(2, 2).Value
strFile = Worksheets("Standards").Cells(10, 2).Value
strShell = strPath + " " + strFile
strName = "UserSheet2.xls"
ResStart = Shell(strShell, 1)
etc.
Now, I want to check whether a certain user file (UserSheet2.xls) has already been openend and I include before the Shell command:
This check is unsuccessfull, even if UserSheet2.xls is definitively open. However, should I have started up manually my second worksheet UserSheet2.xls, not via ShellProg, then the same test is successful.strName = "UserSheet2"
If bFileOpen((strName)) Then
Etc.
Function bFileOpen(wbName As String) As Boolean
Dim wb As Workbook
'check each open workbook's name, in lower case, and set the function
'to true if a match is found. If not match the function defaults to False
For Each wb In Workbooks
If LCase(wb.Name) = LCase(wbName) Then
bFileOpen = True
Exit Function
End If
Next
End Function
So, there seems to be a difference between spreadsheets having been started up through a shell and the same spreadsheets having been started up manually by double clicking on the file name.
Also, after my spreadsheets have been started up through the ProgShell program, I could delete ProgShell itself, but the same difference exists: the spreadsheets having been started by ProgShell act differently from the same spreadsheets having been started by hand, even though the starter program ProgShell has already gone.
Can somebody explain this, please?
Thanks in advance,
Roel
Bookmarks