x

VB Script

37K

Solutions

20K

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.

I would like to modify a CSV file found at ..

C:\users\user\Desktop\file.csv
A sample of the data is found below.
However there could be thousands of lines.

"Data1","Qty1","Qty2"
"ABC1234","0","0"
"ZDG123","525012","0"
"JKL432","0","0"
"TYI00121-1","0","0".
"No of Items","4",""

I want to modify it using a Script so that it searches through the file and when it sees ZDG123, or any other numbers that I will specify in position 1, that it will take the Quantity showing and divide it by 1000, and then re-write the file with the correct changed data.   For example for line shown above as:  "ZDG123","525012","0",  it will then become:   "ZDG123","525.01","0"

Would this be possible, using a scipt?
1
In a VB Script, I can get this line of code to open up my targeted app (assume for illustration purposes that 'app = "C:\Program Files (x86)\SomeAppFolder\SomeApp.exe":

objShell.ShellExecute app

What's the syntax to add to the above line of code to open the 'app' with a target file (e.g. how to I get 'app' to execute on say  ' f = "C:\Users\MyName\Desktop\testfile.txt" '?

If used different variations such as the following with no success:

Thx
0
I have a client who has an application which involves a combination of VBScript and Access to download data from an FTP site and then process that data into multiple Access databases. I'm not happy with the way this was implemented but I'm stuck with it.

I received an email this afternoon which indicates that about 15-20 of the files that should have been downloaded and processed on Monday did not make it into the Access databases.

Indications are that something occurred on there servers which affected their authentication service.  Any chance that this would have affected ADO communications between the VBScript and the Access BE databases?  I'm not a huge fan of VBScript or ADO and don't use either often enough to know what will or will not affect them.

Dale
0
Hi Experts,

I have attached a VB Utility being regularly used by me. It is used to prepare some returns, where we input the data and the output is produced in the shape of some encrypted file format for onward submission. But it can also be used to prepare a correction return also. In that case we need to import a Consolidated file and then the return can be amended or extended.

What I presently do

--Import the files one by one in above software.
>>Here we need to Select Form No (24Q / 26Q / 27Q / 27EQ).
>>Type of statement to be prepared is always "Correction".
>>Option to be selected "Import Consolidated File"

--Copy the data from the tabs and paste them in different sheets of Excel (Normally there are 3 Tabs, but data from 1st Tab is never copy pasted. There may be 4 tabs for the 24Q - 4th Quarter of a Financial year in which case the last 3 tabs are copy pasted)

Name of Tabs (from which data to be copied and pasted in Excel) in case of each Form
24Q >  Challan , Annexure I        (in case of 4th Quarter of FY tabs to be Copy pasted are Challan, Annexure I and Annexure II
26Q >  Challan , Annexure I
27Q >  Challan , Annexure I
2EEQ >Challan , Annexure I

Challan Data can be pasted in the same Excel Sheet for All Form Types, whereas for Annexure I and Annexure II, we need separate sheets for Each Form.

I wish some script (or anything like that even if that is in Excel) which can
0
why doesn't this work.? see attachment

Option Explicit
Dim WithEvents IE As InternetExplorer

Set IE = New InternetExplorer
IE.Visible = True
MsgBox ""
IE.document.getElementById("q").Value = "TEST"

End Sub
0
I have a VB script that I want to adapt to remove a desktop link from the currently logged on user's Desktop.  It isn't working and I get no error messages - no nothing.

On Error Resume Next
Dim FSO, WSHShell, Regkey, Username, strFolder, UserPath, objShell

Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\"

Set FSO = CreateObject("Scripting.FileSystemObject")
strFile = "C:\Users\" & Username & "\Desktop\CMS Supervisor*.lnk}"
if FSO.FileExists(strFile) = True then  FSO.DeleteFile DesktopPath & "\CMS Supervisor*.lnk"

1
I have a setup of 2 PC's connected in Master and Slave configuration through a network cable with Windows 7 OS on both PC's. I need to stop a exe program and do a replace of the corrupted files  in a saved location and restart the exe program through vbscript with progress bar.  Can someone help with a vbscript or guidance? I am not a programmer. The progress should be shown on the master

Vicki
1
Im trying to pin standard office 2013 items to the taskbar for a 2012 R2 RDS farm. After some extensive googling Ive managed to do it but the behaviour isn't what I was expecting:

I have a loopback policy in one GP applied and another GP to run the logon script for the user.

I have a logon script as below:

/timeout /t 5 /nobreak

/timeout /t 5 /nobreak

/timeout /t 5 /nobreak

/timeout /t 5 /nobreak

/timeout /t 5 /nobreak


which calls this:

' Windows Script Host Sample Script
'
' ------------------------------------------------------------------------
'               Copyright (C) 2009 Microsoft Corporation
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files

0
Hi Bill,

You amended some code for me a few weeks ago which worked perfect.. see code below

Option Explicit

' Define files and folders to work with (NO TRAILING BACKSLASH)
Const cBaseDir = "b:\ee\ee29122035\files\[[DATE]]"
Const cControlFile = "b:\ee\ee29122035\list.csv"
Const cDelim = ","

' Text file I/O constants
Const ForWriting = 2
Const ForAppending = 8

' Declare global variables
Dim objFSO, strBaseDir, strControlFile, strDate
Dim arrControl, strControl, arrFields, i, arrTemp
Dim strOldName, strNewName, strOldPath, strNewPath

' Create file system object
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

' Get date in YYYYMMDD format
strDate = Year(Now) & Right("0" & Month(Now), 2) & Right("0" & Day(Now), 2)

' Resolve file paths
strBaseDir = objFSO.GetAbsolutePathname(Replace(cBaseDir, "[[DATE]]", strDate, 1, -1, vbTextCompare))
strControlFile = objFSO.GetAbsolutePathname(cControlFile)

' Make sure base folder exists
If Not objFSO.FolderExists(strBaseDir) Then
Wscript.Echo Now & " ERROR: Base folder does not exist - " & strBaseDir
Wscript.Quit
End If

' Make sure control file exists
If Not objFSO.FileExists(strControlFile) Then
Wscript.Echo Now & " ERROR: List file does not exist - " & strControlFile
Wscript.Quit
End If

' Load csv file into array
.Close
End With

' Loop over each control record and process

0
I need help with vbscript that can refresh a web page (  Internet Explorer and Firefox )
I need to call it as a function whenever I want to refresh a webpage for IE or for Fire Fox
1
Hi All
I have a simple vb script that opens IE window and navigates to a link:

Set oIE=createobject("internetexplorer.application")
Do While (oIE.Busy)
Wscript.Sleep 250
Loop

Most of the time it works fine but sometimes I am getting "Invalid procedure call or argument" error on  oIE.navigate line
Is there anything I am doing wrong?

Thanks
0
Below vbscript code (.VBS)  changes Date format of one of the date column (Date)  from to "mm/dd/yyyy"  to "dd/mm/yyyy" . when saved to Excel.

Row Number|Row Action|Department|Date
123456          |Insert          |Airlines         |05/12/2016
3456              |Update       |Engineering |10/31/2014
234234         |Insert          |Arts                |2015
452435         |Insert          |Design           |2016

' Define constants
Const cExcel7 = 51
Const xlContinuous = 1
Const xlEdgeBottom = 9
Const xlEdgeLeft = 7
Const xlEdgeRight = 10
Const xlEdgeTop = 8

' Create file system object
Set objFSO = CreateObject("Scripting.FilesystemObject")

' Files to work woth
strInputFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\Input.txt")
strInputExcelFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\Input.xlsx")
strOutputFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\output-23-10.xlsx")

' Read text file into array
With objFSO.OpenTextFile(strInputFile, 1)
End With

' Start Excel, create a new worksheet
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objexcel.Application.SheetsInNewWorkbook = 3
Set objSheet = dwb.Worksheets(1)

' Initialize row index
intRow = 0

' Process each line of input file
For Each strInput in arrInput

' Skip all blank lines
If strInput <> "" Then
…
0
VBScript changes dates format upon converting .txt data  to .xlsx sheet.  Date format "DD/MM/YYYY" in Input.txt changes to "YYYY/MM/DD"  upon saved in excel sheet .

Input.txt

Row Number|Row Action|Department|DateOfService

123456          |Insert          |Airlines         |12/02/2016
563455          |Insert          |Engineering |24/12/2013
567897          |Insert          |Science         |01/12/2011
356434          |Update       |Airlines         |23/09/2013

Date format of DateOfService  (DD/MM/YYYY) changed to (YYYY/MM/DD) . Could you please help to resolve this issue in VBScript.

i.e DateOfService in output file converted to (YYYY/MM/DD).
0
I am looking to copy and paste data from one xlsx sheet to a new excel sheet using VBScripts . Could please some one help me using Vb script to paste exact contents from
excel-input.xlsx to a new excel excel-output,xlsx on sheet2   and rename sheet2 to DataSet.

Here is the

Excel-Input.xlsx
Name      age      gender      department      year
don                23      male      computer      2010
ptalakes       24      female      maths              2015
chang      28      male      arts                2016
prag      29      female      science              2018
tom               26      male      arts                      2017
john      27      female      sports              2018
simon      22      male      arts                      2018

Excel-Output.xlsx  (Rename sheet2 as data )
Name      age      gender      department      year
don                23      male      computer      2010
ptalakes       24      female      maths              2015
chang      28      male      arts                2016
prag      29      female      science              2018
tom               26      male      arts                      2017
john      27      female      sports              2018
simon      22      male      arts                      2018
Excel-input.xlsx
Excel-Output.xlsx
0
How can I modify this script so that it pulls the BCC emails from a file, a text file for instance?

SubjectDate = InputBox("Date to be added to the subject:", "Enter date")
MailTo = "email1@gmail.com"
From = "mainemail@someprovider.com"
Subject = "This is a test " & SubjectDate
Body = "Hi, This is an VBScript to send email, Regards, User."
BCC = "email2@gmail.com"

Set objMessage = CreateObject("CDO.Message")
With objMessage
.Subject = Subject
.From = From
.To = MailTo
.BCC = BCC
.TextBody = Body
End With
With objMessage.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
End With
Set

1
Hello everybody.

I've been dealing with a work that, unfortunately, will be in the hands of users with very poor expertise about Excel and pc.

The scenario is as follows. Every morning, before calling a macro (not discussed in this post) that produces a report, an user has to arrange some settings.
I have to "route" the user in the correct settings, exploiting dropdowns where it is possible and building a system of alerts highlighting incoherent choices.

As for me, I set up a VBA code in the sheet "Driver" - where the settings have to be arranged - consisting in a change event calling the macro update_driver at every change in the sheet.
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("A2:J51")) Is Nothing Then Call update_driver

End Sub


With the help of dropdowns built with Data Validation List, I've taken some steps forward, but there is always something to arrange. So, I was wondering if my way is the right one.

Put in practical terms: in column A the user has to type the city where the brenchs are located, and, like I've written, could modify them every day (also deleting some of them). For every brench in column A, a closed choice YES/NO has to be made in column B and C (of course same row).

In column E the user has to type - or delete if necessary  - the agent's surname, in column F has to type the agent's code, and in column G has to make a closed choice YES/NO.
As you can see in attachment dd2, …
0
I have googled this one and despite numerous suggestions I have not succeeded and yet it seems so simple.
In visual studio community 2017 edition, I have a vb web application which includes an XML file of program settings which I do not want to embed, I want it to stay as an .xml file so the site's behavior can be altered without recompilation.
When I run the web application in debug , the output folder shows the web app DLL of the compiled web app and no XML file and the program fails to locate it.
The file is set to Copy to Output directory and I have tried Content, Additional Files, None, to no avail, it never copies.  If I copy the XML file to the output folder whilst in debug mode it works so the question is why does my XML file not copy to the output directory.
I have included the xml file at the top level of the project.
What needs to happen for the web app to copy the XML file to the temporary debug iis express folder so my website can find it and work?
Thank you,
0
I am trying to post an  xml file to a website that uses https and TSL1.2 with the following vbscript.  I supsect the TSL1.2 requirement is casuing the failure point .  I do get back
error 80072EE6  "the url does use a recognized protocol"  .  The vbs code is as follows:

Dim xmlhttp

Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")

' Indicate that page that will receive the request and the
' type of request being submitted
xmlhttp.Open "POST", " https://xxxxx.xxxx.xxxxx.xxxxx/data.xml", False

' Indicate that the body of the request contains form data

' Send the data as name/value pairs
xmlhttp.send "Id=1&S=2"

Set xmlhttp = Nothing


Any thoughts
0
How to search pdf files for a key word like "Sticky" and report those pdf files with that key word. One example is attached.

Regards,

Dallag
CONCLUSIONS-AND-RESULTS.pdf
0
This is to find out about 100+ Windows Servers in our production. All these servers were joined Windows AD domain.  We wanted to know on each individual server, what is the Windows Server version installed, CPU core and some other hardware information.

Do we need to have the administrative privileges? How about if we don't have the privilege? Would powershell manage to do the job?

0
what commands in vbs will move files out from one folder to another?
0
What are the strings of commands in CUTEFTP to download all files found in a specific remote folder?
Either it can override all local files, or it should only download the latest files it finds which are not on the local folder.
0
I am looking to find out if there are Visual Basic Scripts to pull the last time the group policy was updated in the registry.    I have see an example for this in PowerShell, just not in Visual Basic scripting.
0
I have converted a java program to VB program.

After converting, When I am trying to run the program, I am getting some errors. Please suggest if any help

Imports java.io.File
Imports java.io.FileNotFoundException
Imports java.io.FileOutputStream
Imports java.io.IOException
Imports java.sql.Connection
Imports java.sql.DriverManager
Imports java.sql.ResultSet
Imports java.sql.SQLException
Imports java.sql.Statement
Imports java.text.SimpleDateFormat
Imports java.util.Calendar
Imports java.util.Map
Imports java.util.Set
Imports java.util.TimeZone
Imports javax.activation.DataHandler
Imports javax.activation.FileDataSource
Imports java.util.Star
Imports javax.mail.Star
Imports javax.mail.internet.Star
Imports javax.activation.Star
Imports javax.mail.Session
Imports javax.mail.Transport
Imports org.apache.poi.hssf.usermodel.HSSFCell
Imports org.apache.poi.hssf.usermodel.HSSFCellStyle
Imports org.apache.poi.hssf.usermodel.HSSFFont
Imports org.apache.poi.hssf.usermodel.HSSFRow
Imports org.apache.poi.hssf.usermodel.HSSFSheet
Imports org.apache.poi.hssf.usermodel.HSSFWorkbook
Imports org.apache.poi.hssf.util.HSSFColor
Imports org.eclipse.swt.SWT
Imports org.eclipse.swt.ole.win32.OLE
Imports org.eclipse.swt.ole.win32.OleAutomation
Imports org.eclipse.swt.ole.win32.OleClientSite
Imports org.eclipse.swt.ole.win32.OleFrame
Imports org.eclipse.swt.ole.win32.Variant
Imports …
0
I try to automate some handling on a webpage. I have read all the articles I could find, but it just does not fit.

This is partial the webpage:

This is the HTML beneath:

<div class="rgWrap rgArrPart2">
<a title="Go to Next Page" href="javascript:__doPostBack('ctl00j','')">Volgende</a>
<input type="submit" name="ctl003" value=" " title="Next Page" class="rgPageNext" />
<a title="Go to Last Page" href="javascript:__doPostBack('ctl004','')">Laatste</a>
<input type="submit" name="ctl005" value=" " title="Last Page" class="rgPageLast" />

"Volgende" en "Laatste" are Dutch for "Next" and "Last".

The code which I try to build needs to click on the "Volgende" so I get the next page with records.

I have tried the following code:

GetElementById():

   IE.Document.GetElementById("ctl00j").Click()

GetElementsByTagName() and filter by value:

Set oInputs = IE.Document.GetElementsByTagName("input")
For Each elm In oInputs
If elm.Value = "Go to Next Page" Then
elm.Click
Exit For
End If
Next

GetElementsByClassName():

    For Each elem In IE.Document.GetElementsByClassName("rgPageNext")
If elem.innerText = "Go to Next Page" Then
elem.Focus
elem.Click
End If
Next

GetElementsByTagName() and filter by class attribute:

    For Each a In IE.document.getElementsByTagName("a")
If a.GetAttribute("class") = "rgPageNext" Then
a.Click
Exit For
End If
Next

GetElementsByTagName() and filter by title attribute:

    For Each a In IE.document.getElementsByTagName("a")
If a.getAttribute("title") = "Go to Next Page" Then
a.Click
Exit For
End If
Next

The first approach gives this error message:

    Script: K:\temp\TT\mftt.vbs
Line: 37
Char: 2
Error: Object required: 'IE.Document.getElementByID(...)'
Code: 800A01A8
Source: Microsoft VBScript runtime error

The other attempts are not giving error messages but also no reaction on the link to click. I'm missing here the OnClick event. With other links in this project the OnClick event was present. I can't change the HTML, so I'm stuck.

UPDATE1: I have added the script file so far. I have not attempt to build the logic. First aim is to read all the fields and click the right buttons. If that is successful I will build the iteration process,
UPDATE2: due to privacy reasons I can't give you access to the site. I have added the DOM from the page and removed any names.
mftt2.txt
DOM.txt
Transactiehistorie.txt
0

VB Script

37K

Solutions

20K

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.