Solved

Username parameter

Posted on 2010-11-10
3
449 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 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

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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 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