Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Drawing and Graphics

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 06-10-2010, 02:15 AM
Swarv Swarv is offline Windows XP Office 2003
Novice
 
Join Date: Feb 2010
Posts: 7
Swarv is on a distinguished road
Default word macro username

Hi all,


I have a macro in word but would like to change 1 line to have a username in it.
at the moment the line reads:
\\server\users\mstorey\winword\template
is there any way of changing the bit that says mstorey to something like username?
so when I roll it out to users to picks up their username and then places it in that place?
Thanks
Martin
Reply With Quote
  #2  
Old 06-10-2010, 04:17 AM
Kimberly Kimberly is offline Windows 7 Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Posts: 517
Kimberly is on a distinguished road
Default

HTML Code:
    Selection.TypeText Text:="\\server\users\"
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
        "USERNAME  \* Lower ", PreserveFormatting:=True
    Selection.TypeText Text:="\winword\templates"
Reply With Quote
  #3  
Old 06-10-2010, 04:43 AM
Swarv Swarv is offline Windows XP Office 2003
Novice
 
Join Date: Feb 2010
Posts: 7
Swarv is on a distinguished road
Default

Many thanks for that - it looks good.

Just a quick one - how would I insert that in to this line?

Documents.Add Template:="\\neptune\users\%username%\WINWORD\TEMPLATE\TCH LETTER.dot", _
NewTemplate:=False


Thanks
Reply With Quote
  #4  
Old 06-16-2010, 06:05 AM
Swarv Swarv is offline Windows XP Office 2003
Novice
 
Join Date: Feb 2010
Posts: 7
Swarv is on a distinguished road
Default

Hi all,

any ideas on the above?

Thanks
Reply With Quote
  #5  
Old 06-16-2010, 09:05 AM
Kimberly Kimberly is offline Windows 7 Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Posts: 517
Kimberly is on a distinguished road
Default

Code:
 
 
Documents.Add Template:="\\neptune\users\" & Environ("UserName") & "\WINWORD\TEMPLATE\TCH LETTER.dot", _
NewTemplate:=False
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2003 macro to Word 2007 to 2010 to... maruapo Word VBA 0 06-04-2010 03:43 PM
Word Macro Tutorial Jax Word VBA 0 04-27-2010 09:13 PM
Word macro weezypenguin Word 0 02-25-2010 01:25 PM
Problem with AutoClose macro and Word 2003 cholo Word VBA 0 07-08-2009 05:48 AM
Word 2000 Macro not working properly brianlb Word VBA 1 07-01-2009 07:04 AM


All times are GMT -7. The time now is 02:22 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft