[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Username parameter

Posted on 2010-11-10
3
Medium Priority
?
451 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

650 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