Two questions?
1. Here is macro that determins if workbook is already opened, but it doesn't work. can somebody help me to make it work?
2. Workbook opens depending on cell value -> Workbooks.Open FileName:= _
("D:Dreid" & Sheets("Radne knjige").Range("B1").Value).
Each workbook has Autpen macro that should open a certan userform (each workbook a diferent one). When workbook opens nothing hapens. I've tried "Application.Run (Sheets("Radne knjige").Range("B1").Value)!Autpen)" but it has only laught at me.
Here is whole macro:
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
Sub provjera()
Application.ScreenUpdating = False
If bFileOpen("D:Dreid" & Sheets("Radne knjige").Range("B1").Value) Then
Exit Sub
End If
If Not bFileOpen("D:Dreid" & Sheets("Radne knjige").Range("B1").Value) Then
ChDir "D:Dreid"
Workbooks.Open FileName:= _
("D:Dreid" & Sheets("Radne knjige").Range("B1").Value)
Application.Run "Autpen"
Workbooks("Dreid.xls").Save
Workbooks("Dreid.xls").Close
End If
End Sub
THNX
1. Here is macro that determins if workbook is already opened, but it doesn't work. can somebody help me to make it work?
2. Workbook opens depending on cell value -> Workbooks.Open FileName:= _
("D:Dreid" & Sheets("Radne knjige").Range("B1").Value).
Each workbook has Autpen macro that should open a certan userform (each workbook a diferent one). When workbook opens nothing hapens. I've tried "Application.Run (Sheets("Radne knjige").Range("B1").Value)!Autpen)" but it has only laught at me.
Here is whole macro:
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
Sub provjera()
Application.ScreenUpdating = False
If bFileOpen("D:Dreid" & Sheets("Radne knjige").Range("B1").Value) Then
Exit Sub
End If
If Not bFileOpen("D:Dreid" & Sheets("Radne knjige").Range("B1").Value) Then
ChDir "D:Dreid"
Workbooks.Open FileName:= _
("D:Dreid" & Sheets("Radne knjige").Range("B1").Value)
Application.Run "Autpen"
Workbooks("Dreid.xls").Save
Workbooks("Dreid.xls").Close
End If
End Sub
THNX