?
Solved

Username parameter

Posted on 2010-11-10
3
Medium Priority
?
450 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

770 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