Word Macro doesn't seem to be executing any API function calls

  • Thread starter bluejackethive72
  • Start date
B

bluejackethive72

I am working with a Word Macro. In the macro there are calls to
GetTempPathA API function. A client has XP and Word 2000 and the return
value of this call is 0 with no dll error number. So far this is the only
client that has this problem. Here is the code for the call:
Private Declare Function GetTempDir Lib "kernel32" Alias "GetTempPathA"
(ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long

Const MAX_PATH = 260
Dim lReturnVal As Long
Dim sTempDir As String * MAX_PATH
Dim lLastDllError As Long
Dim errDesc As String

On Error GoTo Handle_Error

lReturnVal = GetTempDir(MAX_PATH, sTempDir)
If lReturnVal = 0 Then 'error
lLastDllError = Err.LastDllError

I work with another program that is written in Visual Basic and makes the
same call to get the temporary directory and writes a file in the directory.
The Word macro now needs to read this file, so I know the API calls are
working for VB but not for VBA.

Does anybody have an idea of what might be the problem?
 
J

Jay Freedman

The best I can do is tell you that this problem has been seen before,
but no resolution was found. Google Groups turned up these two
threads:

http://groups.google.com/group/micr...rosoft.public.*&rnum=1&hl=en#fd26c8fcb2625d88
http://groups.google.com/group/micr...rosoft.public.*&rnum=2&hl=en#e0a40db573fe499c

If you can use the Environ("Temp") function instead, that may work
where the API call doesn't.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top