Solved

Username parameter

Posted on 2010-11-10
3
444 Views
Last Modified: 2012-05-10
In the following code I will like to use the username variable instead of the hardcoded  "c:\excelver.dat". So if the username is cis7777, I want the code to open
"c:\cis7777.dat" file.

Help

Thanks
Cheers



option explicit

    Dim oSession        ' AS NotesSession
    Dim strServer
    Dim strUserName
    Dim strMailDbName
    Dim oCurrentMailDb  ' as NOTESDATABASE
    Dim oMailDoc        ' as NOTESDOCUMENT
    Dim ortItem         ' as NOTESRICHTEXTITEM
    Dim ortAttacment    ' as NOTESRICHTEXTITEM
    Dim oEmbedObject    ' as ????
    dim cstrAttachment
    Dim blAttachment

    cstrAttachment = "c:\excelver.dat"

Dim xl, ver, vers
On Error Resume Next
Set xl = CreateObject("Excel.Application")
On Error Goto 0
If xl is Nothing then
      vers = "Microsoft Excel not installed"
Else
      ver = xl.Version
      xl.Quit
      Set xl = Nothing

      Select case Int(left(ver, InStr(ver, ".")-1))
      Case 14   : vers = "Microsoft Excel 2010"
      Case 12   : vers = "Microsoft Excel 2007"
      Case 11   : vers = "Microsoft Excel 2003"
      Case 10   : vers = "Microsoft Excel 2002"
      Case 9    : vers = "Microsoft Excel 2000"
      Case 8    : vers = "Microsoft Excel 97"
      Case 7    : vers = "Microsoft Excel 95"
      Case else : vers = "Microsoft Excel (unknown version)"
      End Select

End If
0
Comment
Question by:Bianchi928
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 250 total points
ID: 34108072
You could use something like this

Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
 cstrAttachment = "c:\" & WshNetwork.UserName & ".dat"

0
 

Author Comment

by:Bianchi928
ID: 34108129
That works fine..I have one more little thing to ask....How do I go about checking if the file "c:\" & WshNetwork.UserName & ".dat" exist from a previous run and delete it first it it exists.

Thanks
Cheers
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34108219
Try this

Dim fso
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
strFile = "c:\" & WshNetwork.UserName & ".dat")
If fso.FileExists(strFile) Then
fso.DeleteFile(strFile)
End If
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now