More Help with MS Function

  • Thread starter Thread starter TC
  • Start date Start date
Hi;

I'm trying to run a module with a function that just
opens a .hlp (help) file. I can't use the
provided "help" utility from the custom toolbar because
before the file opens, I get a message that the file may
contain viruses, blah, blah. BS from MS! Obviously, I
don't want my customers to see that message before the
help file "tree" comes up. I went out to the knowledge
base about this message and found out there's no way to
get rid of it. I'm more than just a little aggrevated
with Microsoft. So, in the past three days I've posted
quite a few questions out here.

PROBLEM: I have been programming mainframes for 20+
years, but I don't understand functions at all. I have
been getting some help out here, but none of it seems to
work. I will get a compile error, or other MS Access
message meaning I don't have the function right.

This is the latest error I've been getting:
"Microsoft Access can't find the name '<<PathDirName>>'
you entered in the expression. Folling is the code of
the module. I call the first function first and then get
the error on the second function. Can anybody tell me
what I'm doing wrong? For all of you who have helped me
before, I am gratefull... just can't seem to get it
working even with your help.

-------------------------------------------------------
Option Compare Database
Public PathDirName As String

Function SetValue()
PathDirName = "C:\Access Projects\Development PP1.5
\ProjectST15.hlp"
End Function

'The next function is supposed to open the help file
'without the Microsoft "virus" warning, but it's tripping
'over PathDirName. I don't know if the rest of the code
'will work either.

Function wshRun(PathDirName As String)

Dim wShell As Object 'wshShell

Set wShell = CreateObject("WScript.Shell")
If Left(PathDirName, 1) <> Chr(34) Then
PathDirName = Chr(34) & PathDirName & Chr(34)
End If
wshRun = wShell.Run(PathDirName)
Set wShell = Nothing

End Function
---------------------------------------------------------

Later on, in the first function, I am going to load the
path/directory that my frontend resides on, but for now I
just want to hardcode it, get it working and see if it
gets rid of the BS from MS message.

Thanks to everyone again, (can you tell I'm getting
PO'd? :-)
Dan
 
Dan Bair said:
Hi;

I'm trying to run a module with a function that just
opens a .hlp (help) file. I can't use the
provided "help" utility from the custom toolbar because
before the file opens, I get a message that the file may
contain viruses, blah, blah. BS from MS! Obviously, I
don't want my customers to see that message before the
help file "tree" comes up. I went out to the knowledge
base about this message and found out there's no way to
get rid of it. I'm more than just a little aggrevated
with Microsoft. So, in the past three days I've posted
quite a few questions out here.

PROBLEM: I have been programming mainframes for 20+
years, but I don't understand functions at all. I have
been getting some help out here, but none of it seems to
work. I will get a compile error, or other MS Access
message meaning I don't have the function right.

This is the latest error I've been getting:
"Microsoft Access can't find the name '<<PathDirName>>'
you entered in the expression. Folling is the code of
the module. I call the first function first and then get
the error on the second function. Can anybody tell me
what I'm doing wrong? For all of you who have helped me
before, I am gratefull... just can't seem to get it
working even with your help.

-------------------------------------------------------
Option Compare Database
Public PathDirName As String

Function SetValue()
PathDirName = "C:\Access Projects\Development PP1.5
\ProjectST15.hlp"
End Function

'The next function is supposed to open the help file
'without the Microsoft "virus" warning, but it's tripping
'over PathDirName. I don't know if the rest of the code
'will work either.

Function wshRun(PathDirName As String)

Dim wShell As Object 'wshShell

Set wShell = CreateObject("WScript.Shell")
If Left(PathDirName, 1) <> Chr(34) Then
PathDirName = Chr(34) & PathDirName & Chr(34)
End If
wshRun = wShell.Run(PathDirName)
Set wShell = Nothing

End Function
---------------------------------------------------------

Later on, in the first function, I am going to load the
path/directory that my frontend resides on, but for now I
just want to hardcode it, get it working and see if it
gets rid of the BS from MS message.

Thanks to everyone again, (can you tell I'm getting
PO'd? :-)
Dan

In your second functions code, you "usurp" the name of the public
variable PathDirName by defining a parameter with the same name. The
function definition says
Function wshRun(PathDirName As String)

That defines an *argument* named "PathDirName", which is a different
thing entirely from the public variable that is also named
"PathDirName". But only one of those names can be known inside the
function, so naturally it's the one that is defined most locally. I
programmed mainframes for 25+ years, and I wouldn't expect any different
behavior.

What you don't show us is how you call wshRun(). If you have a line of
code like this:

wshRun PathDirName

or like this:

Call wshRun(PathDirName)

I'd expect it to work -- provided you had previously called SetValue,
and provided the "PathDirName" in the call was resolved to the public
variable you declared. But if your code looks like this:

wshRun "<<PathDirName>>"

you'll certainly get an error.

Have you tried running this line in the immediate window:


wshRun "C:\Access Projects\Development PP1.5\ProjectST15.hlp"

? That's the line I'd expect you to be using to call the function.
 
Thanks Dirk;

I took the DirPath as string stuff out of the function
and it worked fine. I didn't know that would re-
initialize it. I suspected it, but I had so much wrong
with that function initially, when I removed it, I got
another error message. Just the pain of learning a new
skill at my age. Sorry I got snotty.

Dan
 
You will be better off using an API function to open your help file. You
are using VB script and the warning should be expected.
 
Upon further thought, using VBS probably isn't a problem....if used
properly. However, there are API functions that open help files, even
allowing the file to be opened to a specific topic. Using the APIs would
provide for a more robust solution.
 
Back
Top