Please help

Dejan

New Member
Joined
Oct 18, 2002
Messages
24
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 Auto_Open 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)!Auto_Open)" 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 "Auto_Open"

Workbooks("Dreid.xls").Save
Workbooks("Dreid.xls").Close
End If
End Sub



THNX
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
1. You only need to pass the name of your workbook to the Function, not the full path, eg "Book2.xls". Or use the FullName property instead of the Name property in your Function.

2. You need to use the RunAutoMacros Method to run your Auto_Open procedure, like this:

ActiveWorkbook.RunAutoMacros xlAutoOpen
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,306
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top