VB Script

36K

Solutions

25

Articles & Videos

19K

Contributors

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi ,

I am trying to use HTA with VBScript and Excel for Task list tracking and have done everything with excel protecting with password. Now I want to convert with HTA file to .exe file and package the excel along with it. Is there any way with VBScript to open file without giving full path in the code. I am new to scripting and a help is highly appreciated.

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("D:\Projects\Tracker.xlsx",,,,"xxxx")
Set objsheet = objExcel.ActiveWorkbook.Worksheets(1)

Regards,
Maha.
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi all,

Bit of a strange one this and I wont try and explain the reason I need this as its pretty long winded!

I would like to try and create a logon script, which when triggered executes a wake on lan command (which references a MAC address, ideally in a .csv list or similar) based on which user is logging on.  I hope that makes sense!

Example

User "STEVE" logs on

1.) Logon script is executed

2.) WOL command is triggerd and looks to a CSV file to match up "STEVE" to Mac address 11:11:11:11:11:11

User "DAVE" logs in

1.) Logon script is executed

2.) WOL command is triggerd and looks to a CSV file to match up "DAVE" to Mac address 22:22:22:22:22:22

Would anyone be able to help me achieve this please?

Thank you
0
Hi Guys,

I need help with visual basic syntax.
I"m trying to create dropdown list on my page with @html helper, so in C# which I'm familiar with it looks like this:
 @Html.DropDownList("ddlAdditional1", New SelectList(ViewBag.Listofitem, "", "id"), New { @CssClass="form-control", Width="180px"}  )

Open in new window


but in VB I think the syntax is different and I can't find what is the right one.

I will be appreciate if you can give me the server side code in vb as well.

thanks,
0
I have a list of files to be FTPed from one server to another.  This process had been working.  Recently, only part of each file was successfully sent.  The files are all 20-30kb.  When sent to the 2nd server, only 3-6kb of each file shows up.

The script loops through the list of files and uses this code to FTP them:
Set objshell _ Createobject("wscript.shell")
objshell.run "ncftpput.exe (server stuff and file names)
set objshell = nothing

Open in new window


I tried to slow the process down by adding a msgbox and it worked:
Set objshell _ Createobject("wscript.shell")
objshell.run "ncftpput.exe (server stuff and file names)
set objshell = nothing
msgbox "Press ENTER to continue"

Open in new window


Next, I tried the sleep command to delay it by 20seconds. It did not work. Only parts of the files were transfered.
Set objshell _ Createobject("wscript.shell")
objshell.run "ncftpput.exe (server stuff and file names)
wscript.sleep 20000
set objshell = nothing

Open in new window

0
I have a code that creates a code in a module, but when it does the VBA window flashes up while the code is running.
I have tried 'Application.screenupdating = false', and it does not work, I have also tried    'ThisWorkbook.VBProject.VBE.MainWindow.Visible = False' at the beginning and end of the code but the window still pops up for a short time. I would like to run the code without the vba window being visable at all.

this is the code:



Sub code
   
        Set vbp = Application.VBE.ActiveVBProject
    Set vbc = vbp.VBComponents.add(vbext_ct_StdModule)
    vbc.Name = "CreateButton"
    strCode = "Sub CreateButtons()" & vbNewLine & _
    "ActiveSheet.Buttons.Add(840, 10, 95, 25).Select " & vbNewLine & _
   " Selection.OnAction = ""ClaimsLog""" & vbNewLine & _
    "Selection.Characters.Text = ""Claims Log"" " & vbNewLine & _
  "  With Selection.Characters(Start:=1, Length:=35).Font " & vbNewLine & _
      "  .Size = 10" & vbNewLine & _
   " End With" & vbNewLine & _
 "ActiveSheet.Buttons.Add(840, 40, 95, 25).Select " & vbNewLine & _
   " Selection.OnAction = ""UNM23Report""" & vbNewLine & _
    "Selection.Characters.Text = ""UNM23 Report"" " & vbNewLine & _
  "  With Selection.Characters(Start:=1, Length:=35).Font " & vbNewLine & _
      "  .Size = 10" & vbNewLine & _
   " End With" & vbNewLine & _
 "ActiveSheet.Buttons.Add(840, 70, 95, 25).Select " & vbNewLine & _
   " Selection.OnAction = ""SPLEtool""" & vbNewLine & _
    …
0
For a program i have nearly ready i need some code what i can't find in VB, only in Python.

import serial
import operator

def ibisString( str ):
bytestring = str+" "
bits = chr(0x7f) + bytestring
checksum = reduce(lambda x,y:chr((ord(x)^ord(y))&0xff),bits)
message = bytestring+checksum
output = map(lambda x:hex(ord(x)),message)
bytes = bytearray(int(x, 16) for x in output)
print output
return bytes

ser = serial.Serial(‘/dev/ttyUSB0‘, 1200, parity=‘E‘, stopbits=2, timeout=1)
ser.write(ibisString(‘l300‘))

Open in new window


Can anyone help me to convert this Python code to VB?
0
Hi Experts. I was able to source this VBA code from a question answered but I need to modify it slightly. I have X number of workbooks with Y number of worksheets in each book. I have information that I would like to compile onto a single master data workbook. The code below is able to gather the data from the first sheet from all the selected workbooks. I need it to do the same for the remaining worksheets. Please help me with this request! Would really appreciate the help. :)

Sub MergeTest()

    Dim SummarySheet As Worksheet
    Dim FolderPath As String
    Dim SelectedFiles() As Variant
    Dim NRow As Long
    Dim FileName As String
    Dim NFile As Long
    Dim WorkBk As Workbook
    Dim SourceRange As Range
    Dim DestRange As Range
    Dim LastRow As Long

    ' Create a new workbook and set a variable to the first sheet.
    Set SummarySheet = Workbooks.Add(xlWBATWorksheet).Worksheets(1)

    ' Open the file dialog box and filter on Excel files, allowing multiple files
    ' to be selected.
    SelectedFiles = Application.GetOpenFilename(filefilter:="Excel Files (*.xl*), *.xl*", MultiSelect:=True)

    ' NRow keeps track of where to insert new rows in the destination workbook.
    NRow = 1

    ' Loop through the list of returned file names
    For NFile = LBound(SelectedFiles) To UBound(SelectedFiles)
        ' Set FileName to be the current workbook file name to open.
        FileName = SelectedFiles(NFile)

        ' Open the …
0
I have the following line...

Set objFolder = objShellApp.Namespace("C:\Users\pf1004\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu")

Which only applies to the location within the user PF1004's user profile, but I want to use it in a logon script.  How do I change this to an environment variable, i.e. how do I change the path to something like...

%APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu

I'm unsure about using variables in VB because I've seen people use %varable% and others use $env:variable, and even then I don't kow how to include that in the above path.

Thanks.
0
How can I run a batch file from within a Word macro?
0
Hello,

Can Excel VBA code designate a specific string of text from within a cell in the same way the =MID() function can extract a string of text?

For example, suppose cell B4 contains the following entry:

        The quick brown fox jumped over the lazy dog.1

And suppose that cells D4 & E4 contain the values 11 & 5 respectively. Then the formula =MID(A2,D4,E4) entered in cell G4 would return the string "brown" as shown here:

2017-06-23e_EE.PNG
2017-06-23d_EE.PNG
How could the same three cell values be captured by VBA and assigned to variables to be used further down in the code?

Thanks
0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Need assistance with a powershell/vbs script to do the following:

We need to monitor the following path \\SERVER\folder.  When a new folder is created that's an indication of a failure of a background process. Once the new folder is detected we need to send an email alert. We are looking to received the alert only when newly created folders (now-15 minutes or so)or just the last date (compare with the most recent folder date creation) if newer then sent alert.

We do have SCOM and so we might run the script from there otherwise from the server itself (windows server)

Can you someone please assist
0
VBA: can someone help me with the code on VBA that takes a screenshot of a specific excel spreadsheet on a specific range of cells and attaches it to an email?
0
I have this Summary tab and different supplier tabs that are linked from an access table that I need information pulled from to populate the Summary sheet.  Wanted to see if this is possible to accomplish by entering a number instead of manually entering this information.

Basically if you enter the RFQ number in cell B3 then it would pull it's corresponding row information and populate the specific cells in the summary sheet tab.  See example in the attachment.
C--Users-Luis.Freund.EXT-Desktop-Lu.xlsm
0
Hi Experts,

I am trying to update legacy ASP code amd I am starting out with
<%@ Language=VBScript %>

<%
Session("isLocal") = True

Session("getRates") = ""
Session("getRatesTime") = DateAdd("n", -1, Now())	'DateAdd Intervals: s=secs; n=minutes; h=hrs

Session("Root") = "../"
Session("sourceID") = 1

If (Session("isLocal") = True) Then   
    %>

    <!--  <!-- #include file = "../../CSSN_subdomains/includes/common.asp" -->
    <!--  <!-- #include file = "../../CSSN_subdomains/includes/functions.asp" -->
    <!--  <!-- #include file = "../../CSSN_subdomains/includes/PageSetup.asp" -->

    <%
Else
    %>

    <!--  <!-- #include virtual = "/includes/common.asp" -->
    <!--  <!-- #include virtual = "/includes/functions.asp" -->
    <!--  <!-- #include virtual = "/includes/PageSetup.asp" -->

    <%
End If

Open in new window


However, I am getting the following error despite that Session("isLocal") is True, so lines 23-25 should never be executed.
Active Server Pages error 'ASP 0126'

Include file not found

/CSST_subdomains/cart.citysightseeingtoronto.com/index.asp, line 23

The include file '/includes/common.asp' was not found.

Open in new window


What is going on?

Any help will be greatly appreciated.
0
If have two fields in a form.

the item number (item) and Count (stored as a string)

I want to be able to compare to see if the item number box and the count box are the same value.

We use barcode scanner (wireless keyboard/scanner) so the info is read from a barcode.  the enter key is pressed as part of the entry, so the cursor moves to the next field.  if the user "double scans" I want to check when the cursor leave the count box, if it is the same at the item box.  If so, I want to be able to clear out the count and let the user re-enter it (without them having to take any action.  So I declared a local variable and want to see if they are the same.  It's like the function does not work, does not matter what is in EITHER BOX, the resulting msgbox always has an answer of 1 (never -1 or 0)
  Dim CompResult As Integer
...
 CompResult = StrComp(Me.Item.Value, CountAsString, vbTextCompare)
 
  MsgBox ("And the boolean comparison results (< -1, = 0 , >1) = " & CompResult)
0
Since we upgraded to SQL 2008 from SQL 2000 i have faced the following problem: I can run the VB Script that runs a DTS from the SQL Server, however running the same VB Script to to execute the DTS from a client PC has the above error message. I have tried, installing MS SQL studio on the client connecting to the DB instance and tried running the VB Script but it still wont work. im lost, please help

Regards,
Grand
0
New to powershell

Looking to create a powershell script that will delete all files in folder and sub folders past a certain age.

Thank you
0
hi all
i want a line per ittem, please help

ObjSendMail.HTMLBody = "Nombre:" +" " + Request.Form("fname") & Chr(10) & "Email:" +" " + Request.Form("email") & Chr(10) & "Consultorio:" +" " + Request.Form("consultorio") & Chr(10) & "Comentarios:" +" " + Request.Form("message")

Open in new window


tsm
0
I have this code which will find matching sets of three numbers (and colour them for ID) across a worksheet. (sample sheet attached 007-quad-ID-query-ee.xls )

Could it be adjusted to find those sets of three numbers which match 5 or more times ?
__________________________
Code :

Option Explicit

Private Type Sets
    strAddr As String
    strCells As String
    lngColor As Long
End Type

Sub IdentifyDuplicates()

    Dim lngLastRow As Long
    Dim lngLastColumn As Long
    Dim lngRow As Long
    Dim lngCol As Long
    Dim DupeSets() As Sets
    Dim strSet As String
    Dim lngFind As Long
    Dim lngFound As Long
    Dim lngColors()
    Dim lngNextColor As Long

    lngColors = Array(13494512, 11599871, 13626575, 15723724, 15258845, 12178907, 8518399, 11461045, 14667418, 14136257, 10074816, 5369343, 9491089, 14071663, 12683685, 13233150, 11596768, 14541491, 15259071, 15654653, 10668797, 7791807, 12504966, 13674644, 13743867, 8759804, 6146693, 10728776, 12552565, 11963641, vbYellow)
    lngNextColor = 0

    ReDim DupeSets(0)
    lngLastRow = Range("A65536").End(xlUp).Row
    lngLastColumn = Cells.Find("*", SearchOrder:=xlByColumns, LookIn:=xlValues, SearchDirection:=xlPrevious).Column

    For lngRow = 4 To lngLastRow
        If Cells(lngRow, 1) <> "" Then
            For lngCol = 8 To lngLastColumn Step 4
                strSet = Cells(lngRow, lngCol) & "," & Cells(lngRow, lngCol + 1) & "," & Cells(lngRow, lngCol + 2)
                …
0
Enroll in June's Course of the Month
LVL 9
Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

I have this code which sorts groups of 6 numbers into all possible sets of 3 (of which there are 20)

Could someone help and alter it so that it sorts 6 numbers into all possible sets of five please ?

Public Sub Triples()
    intNumbers = 6
    Set wsData = ThisWorkbook.Worksheets("Sheet1")
    For rowCurrent = 4 To wsData.Cells(wsData.Rows.Count, 1).End(xlUp).Row
        colOutput = 8
        For i1 = 1 To intNumbers - 2
            For i2 = i1 + 1 To intNumbers - 1
                For i3 = i2 + 1 To intNumbers
                    wsData.Cells(rowCurrent, colOutput).Value = wsData.Cells(rowCurrent, i1).Value
                    wsData.Cells(rowCurrent, colOutput + 1).Value = wsData.Cells(rowCurrent, i2).Value
                    wsData.Cells(rowCurrent, colOutput + 2).Value = wsData.Cells(rowCurrent, i3).Value
                    wsData.Cells(rowCurrent, colOutput + 3).Value = ""
                    colOutput = colOutput + 4
                Next
            Next
        Next
    Next
End Sub
0
So, I have to look through a worksheet and identify where groups of numbers match.

Could someone help me with code which will do this for me please ?

Also, would it be possible to identify each matching group of number with their own colour ?

I have attached a worksheet to illustrate


thanks
006-triplet-duplicate-id-EE.xls
0
I have code that looks for dups  and removes the second row.

Getting the error on "xlUp"

  Dim i As Long, lastRow As Long

lastRow = Range("A" & Cells.Rows.Count).End(xlUp).Row

For i = lastRow To 1 Step -1
    If Application.CountIf(Range("A1:A" & lastRow), Range("A" & i)) > 1 Then _
        Rows(i).EntireRow.Delete
Next i

Open in new window

0
Hi experts, I wish to add 1 day on the edate I have coded below. Something like this (edate + 1). can i do this? Thanks!


Set rs = cn.Execute("Select Proname, REMARK, TheDate, INPro, OUTPro, BALANCE from Stock where PROCODE='" & code & "' And TheDate Between '" & sdate & "' And '" & edate & "' Order by icount")
0
We currently use a Print Script to install and map printers to all users on log in, but are toying with the idea of using Deployed Printers GPO, what have people found the pros and cons of using the two methods above?

Basically we are after a few options...
1. Speed up log in times
2. Make print deployment and management alot easier
0
I have an excel with around 20 fields. I want to validate the excel cell for a specific datatype.
Every cell will have a different datatype.Need help.
0

VB Script

36K

Solutions

25

Articles & Videos

19K

Contributors

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.