plihu
12-05-2014, 01:57 AM
Hi,
I've noticed strange problem with sub Workbook_open,
here's fragment of the code
Private Sub Workbook_Open()
UserWBName = Me.Name
Sheets("Statistics").DTPicker1.Value = Now
Call Import
End Sub
What is imprtant-that Workbook_Open sets string UserWBName the name of workbook and calls procedure Import.
And here's fragment of Import (in different module)
Sub Import()
userWSName = "Statistics"
Workbooks(UserWBName).Sheets(userWSName).Cells(1, 1).Activate
End Sub
Everything is ok, and works fine but the first time when user launch this Excel file.
Then the "yellow label" shows, when user has to enable macros to make it work. If he do so-he receive Run-time error '1004' Activate method of range class failed.
And this is ONLY for the first time, because the next time - when this file is trusted, and yellow label does not show - everything works fine.
Btw I've done some testing and noticed that when I put e.g. application.wait for 2 seconds in Workbook_Open() procedure it also does not work for this first time with yellow label.
I work in big company and I can't enable all macros without notification for all users.
Any suggestions?
thanks for help!
I've noticed strange problem with sub Workbook_open,
here's fragment of the code
Private Sub Workbook_Open()
UserWBName = Me.Name
Sheets("Statistics").DTPicker1.Value = Now
Call Import
End Sub
What is imprtant-that Workbook_Open sets string UserWBName the name of workbook and calls procedure Import.
And here's fragment of Import (in different module)
Sub Import()
userWSName = "Statistics"
Workbooks(UserWBName).Sheets(userWSName).Cells(1, 1).Activate
End Sub
Everything is ok, and works fine but the first time when user launch this Excel file.
Then the "yellow label" shows, when user has to enable macros to make it work. If he do so-he receive Run-time error '1004' Activate method of range class failed.
And this is ONLY for the first time, because the next time - when this file is trusted, and yellow label does not show - everything works fine.
Btw I've done some testing and noticed that when I put e.g. application.wait for 2 seconds in Workbook_Open() procedure it also does not work for this first time with yellow label.
I work in big company and I can't enable all macros without notification for all users.
Any suggestions?
thanks for help!