dbTalk Databases Forums  

OutputTo the user's My Documents directory or to TMP?

comp.databases.ms-access comp.databases.ms-access


Discuss OutputTo the user's My Documents directory or to TMP? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John Bartley K7AAY
 
Posts: n/a

Default OutputTo the user's My Documents directory or to TMP? - 01-09-2008 , 07:05 PM






New at macros, trying to send a report to file so it will work on any
machine.

I can't figure out how to send to the TMP directory, or to MY
DOCUMENTS without knowing the user's name... what do I put in the
OutputFile box when creating a macro to send it to either the
environment variable TMP (there's one on every machine), or the
user's MyDocuments directory, without hardcoding for a specific user?

Thank you kindly.

Reply With Quote
  #2  
Old   
Tom van Stiphout
 
Posts: n/a

Default Re: OutputTo the user's My Documents directory or to TMP? - 01-09-2008 , 07:35 PM






On Wed, 9 Jan 2008 17:05:49 -0800 (PST), John Bartley K7AAY
<john.bartley (AT) gmail (DOT) com> wrote:

I don't know how to do this in a macro either (they are so limited I
don't bother with them), but in VBA you could use:
Environ("TEMP")
(note: not TMP)
to get the location of the Temp folder.

To get the My Documents folder you have to do a bit more work. See
this page: http://www.mvps.org/access/api/api0054.htm

-Tom.


Quote:
New at macros, trying to send a report to file so it will work on any
machine.

I can't figure out how to send to the TMP directory, or to MY
DOCUMENTS without knowing the user's name... what do I put in the
OutputFile box when creating a macro to send it to either the
environment variable TMP (there's one on every machine), or the
user's MyDocuments directory, without hardcoding for a specific user?

Thank you kindly.

Reply With Quote
  #3  
Old   
John Bartley K7AAY
 
Posts: n/a

Default Re: OutputTo the user's My Documents directory or to TMP? - 01-10-2008 , 07:05 PM




Quote:
On Wed, 9 Jan 2008 17:05:49 -0800 (PST), John Bartley K7AAY

john.bart... (AT) gmail (DOT) com> wrote:
New at macros, trying to send a report to file so it will work on any
machine.

I can't figure out how to send to the TMP directory, or to MY
DOCUMENTS without knowing the user's name... what do I put in the
OutputFile box when creating a macro to send it to either the
environment variable TMP (there's one on every machine), or the
user's MyDocuments directory, without hardcoding for a specific user?

Thank you kindly.
On Jan 9, 5:35 pm, Tom van Stiphout <no.spam.tom7... (AT) cox (DOT) net> wrote:

Quote:
I don't know how to do this in a macro either (they are so limited I
don't bother with them), but in VBA you could use:
Environ("TEMP")
(note: not TMP)
to get the location of the Temp folder.

To get the My Documents folder you have to do a bit more work. See
this page:http://www.mvps.org/access/api/api0054.htm

-Tom.

Tom, I appreciate your response, but I am still not up to speed on
Access, much less incorporating VBA into the database, so your no-
doubt spot-on proposal is so over my head.

Anyone know how to do this within the confines of Macros sans VBA?

Thank you all kindly.



Reply With Quote
  #4  
Old   
Tom van Stiphout
 
Posts: n/a

Default Re: OutputTo the user's My Documents directory or to TMP? - 01-10-2008 , 08:03 PM



On Thu, 10 Jan 2008 17:05:21 -0800 (PST), John Bartley K7AAY
<john.bartley (AT) gmail (DOT) com> wrote:

I am 99% sure this cannot be done in a macro. You'll have to write
some VBA, or hire someone to do it for you.

-Tom.


Quote:
On Wed, 9 Jan 2008 17:05:49 -0800 (PST), John Bartley K7AAY

john.bart... (AT) gmail (DOT) com> wrote:
New at macros, trying to send a report to file so it will work on any
machine.

I can't figure out how to send to the TMP directory, or to MY
DOCUMENTS without knowing the user's name... what do I put in the
OutputFile box when creating a macro to send it to either the
environment variable TMP (there's one on every machine), or the
user's MyDocuments directory, without hardcoding for a specific user?

Thank you kindly.

On Jan 9, 5:35 pm, Tom van Stiphout <no.spam.tom7... (AT) cox (DOT) net> wrote:


I don't know how to do this in a macro either (they are so limited I
don't bother with them), but in VBA you could use:
Environ("TEMP")
(note: not TMP)
to get the location of the Temp folder.

To get the My Documents folder you have to do a bit more work. See
this page:http://www.mvps.org/access/api/api0054.htm

-Tom.


Tom, I appreciate your response, but I am still not up to speed on
Access, much less incorporating VBA into the database, so your no-
doubt spot-on proposal is so over my head.

Anyone know how to do this within the confines of Macros sans VBA?

Thank you all kindly.

Reply With Quote
  #5  
Old   
John Bartley K7AAY
 
Posts: n/a

Default Re: OutputTo the user's My Documents directory or to TMP? - 01-22-2008 , 02:10 PM



http://www.vbaexpress.com/kb/getarticle.php?kb_id=559
Thanks to Ken Puls who posted the above explanation.

Here, I check to make sure C:\TEMP exists.
If it does not, I create it
If it does, I delete all files named tbl*.xls



Attribute VB_Name = "modKillTempXLS"
Option Explicit

Function FileOrDirExists(PathName As String) As Boolean
'Macro Purpose: Function returns TRUE if the specified file
' or folder exists, false if not.
'PathName : Supports Windows mapped drives or UNC
' : Supports Macintosh paths
'File usage : Provide full file path and extension
'Folder usage : Provide full folder path
' Accepts with/without trailing "\" (Windows)
' Accepts with/without trailing ":" (Macintosh)

Dim iTemp As Integer

'Ignore errors to allow for error evaluation
On Error Resume Next
iTemp = GetAttr(PathName)

'Check if error exists and set response appropriately
Select Case Err.Number
Case Is = 0
FileOrDirExists = True
Case Else
FileOrDirExists = False
End Select

'Resume error checking
On Error GoTo 0
End Function

Function ZapOutputFile() As Boolean
'Test if directory or file exists
If FileOrDirExists("C:\TEMP") Then
Kill "C:\temp\tbl*.xls"
Else
MkDir "C:\temp"
End If
Exit Function
End Function




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.