View Full Version : Trial Code Error
av8tordude
04-17-2010, 11:16 AM
I'm using a code found on this link http://www.vbaexpress.com/kb/getarticle.php?kb_id=475, and its been working well on Win XP & XL 2003, but now that I brought a new computer (w/ Win7 & XL 2007), the code errors, highlighting
Open ObscurePath & ObscureFile For Output As #1. I've came to the conclustion it was not creating the text file to write the date/time stamp, thus creating the error, but I could be wrong. Is there a fix out there that can be used for Win 7 & XL 2007?
mdmackillop
04-17-2010, 11:20 AM
If you have not changed the sample, move the files from the C: root to a subfolder. Windows 7 will not allow forming/changing files via VBA in that location.
av8tordude
04-17-2010, 11:35 AM
Ok, I'm assuming you are talking about this line
Const ObscurePath$ = "C:\"
Which I changed to...
Const ObscurePath$ = "C:\test"
but I'm still getting the same error. Any reason?
mdmackillop
04-17-2010, 11:38 AM
Just the last \ to create the path.
Const ObscurePath$ = "C:\test\"
av8tordude
04-17-2010, 11:53 AM
Thank you for you help!
Always appreciated! :friends:
av8tordude
04-17-2010, 11:55 AM
Out of curiosity, I had this in my code and it errored...
"C:\Windows\System32\"
Any reason why it error?
mdmackillop
04-17-2010, 12:00 PM
I would guess MS see these as restricted areas that we should not meddle in with code.
av8tordude
04-17-2010, 12:02 PM
So how do I create a folder to put the file in it?
mdmackillop
04-17-2010, 12:18 PM
You can do it though Explorer (or whatever they call it now) if it is a one off. If you need to code it, you are permitted to create a sub'folder, and you can then use that
Private Sub Workbook_Open()
Dim StartTime#, CurrentTime#
'*****************************************
'SET YOUR OWN TRIAL PERIOD BELOW
'Integers (1, 2, 3,...etc) = number of days use
'1/24 = 1Hr, 1/48 = 30Mins, 1/144 = 10Mins use
Const TrialPeriod# = 1 '< 1 day trial
'set your own obscure path and file-name
Const ObscurePath$ = "C:\ObscureName\"
Const ObscureFile$ = "TestFileLog.Log"
'*****************************************
On Error Resume Next
MkDir ObscurePath
On Error GoTo 0
'etc.
av8tordude
04-17-2010, 06:51 PM
Thanks again...
is there a way to make TestFileLog.Log file hidden when it gets created?
mdmackillop
04-18-2010, 12:40 AM
SetAttr "C:\Temp\TestFileLog.Log", vbHidden
SetAttr "C:\Temp\TestFileLog.Log", vbHidden
:pleased: I do not believe I've ever seen SetAttr, or at minimum, had most certainly forgotten. Always nice to learn one more 'trick' :thumb
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.