OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 15-11-2005, 08:14
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default Target Desktop

Instead of using this code...
Code:
ActiveDocument.PublishToPDF "C:\Documents and Settings\Artist\Desktop\" & Left(fn, Len(fn) - 4) & ".pdf"
How can I get the current users desktop so that I don't have to change the code for every machine? I don't know if it matteres, but there will be WinXP and Win2K instances of this macro.

I tried to use this, thinking I was on the right track...
Code:
ActiveDocument.PublishToPDF "C:\Documents and Settings\%CurrentUser%\Desktop\" & Left(fn, Len(fn) - 4) & ".pdf"
But that did not work.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #2  
Old 15-11-2005, 09:38
petig
Guest
 
Posts: n/a
Default

What is inside two " -sign that is a string. No process anything for that, what you tried, simply search for a directory named %CurrentUser% -- and found that doesn't exist...
In VB you can use the Environ({envstring | number}) function to return a string associated with an OS environment variable.

envstring: Optional.String expression containing the name of an environment variable.
number: Optional.Numeric expression corresponding to the numeric order of the environment string in the environment-string table. The numberargument can be any numeric expression, but is rounded to a whole number before it is evaluated.

If envstring can't be found in the environment-string table, a zero-length string ("") is returned. Otherwise, Environ returns the text assigned to the specified envstring; that is, the text following the equal sign (=) in the environment-string table for that environment variable.

If you specify number, the string occupying that numeric position in the environment-string table is returned. In this case, Environ returns all of the text, including envstring. If there is no environment string in the specified position, Environ returns a zero-length string.

Try out this code to detect, how it works:
Code:
Sub ShowEnvironmentVariable()
   Dim MyString As String
   MyString = Environ("TMP")
   MsgBox MyString
End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
desktop color tonywong General 1 18-05-2005 20:08
Changed Desktop Settings bobhuey Calendar Wizard 1 18-11-2004 09:51


All times are GMT -5. The time now is 20:54.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com