Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bluejackethive72 - 07 Mar 2006 20:55 GMT
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?
Jay Freedman - 08 Mar 2006 01:14 GMT
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/microsoft.public.excel.programming/browse_frm/thr
ead/da0a0dd7e3fea09b/fd26c8fcb2625d88?lnk=st&q=gettemppatha+group%3Amicrosoft.pu
blic.*&rnum=1&hl=en#fd26c8fcb2625d88

http://groups.google.com/group/microsoft.public.office.misc/browse_frm/thread/38
ba9935c212fb9f/e0a40db573fe499c?lnk=st&q=gettemppatha+group%3Amicrosoft.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        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>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
[quoted text clipped - 22 lines]
>
>Does anybody have an idea of what might be the problem?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.