VB Script

36K

Solutions

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

I am giving my required Excel Template here. As my present scenario this excel will be stored in a fix path. But CSV will generate everyday.

My vb script should execute everyday to collect data from csv and write into this Excel , but small customization needed.

Here First 3 rows are Fixed Header, I need to convert csv and write values in excel from 4th row. but its obvious we have old data there. so it should delete 4th row to 7th row and put csv value as per required place. With proper border also.

Now tell me is it possible to modify my vbs to get this type of output?

srccsvfile = Wscript.Arguments(0)
tgtxlsfile = Wscript.Arguments(1)

'Create Spreadsheet
'Look for an existing Excel instance.
On Error Resume Next ' Turn on the error handling flag
Set objExcel = GetObject(, "Excel.Application")
'If not found, create a new instance.
If Err.Number = 429 Then  '> 0
  Set objExcel = CreateObject("Excel.Application")
End If

objExcel.Visible = False
objExcel.DisplayAlerts = False

'Import CSV into Spreadsheet
Set objWorkbook = objExcel.Workbooks.Open(srccsvfile)
Set objWorksheet1 = objWorkbook.Worksheets(1)

'Adjust width of columns
Set objRange = objWorksheet1.UsedRange
objRange.EntireColumn.Autofit()
'This code could be used to AutoFit a select number of  columns
'For intColumns = 1 To 17
'    objExcel.Columns(intColumns).AutoFit()
'Next

'Make Headings Bold
objExcel.Rows(1).Font.Bold = True

'Freeze header row
With objExcel.ActiveWindow
     .SplitColumn = 0

Open in new window

0
Ready to get started with anonymous questions?
LVL 9
Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

How to send commands to the remote server connected using Mstsc...

I am aware of doing this using Devolutions Remote Desktop Manager and other third party tools but looking for a way to achieve this using windows native tools like PowerShell or any other scripting... I could manage to prepare a tool using PowerShell and windows forms but stuck at logon banner screen where as i am unable to send any commands to the remote server over RDP connection..

any ideas/suggestions ?
0
Every month I have to go through several text files after paying bills online to send to the CFO to show all the bills that have been paid. I have tried to get him to accept a print of confirmation page but instead he wants it in the format of file 2 below (ee-online-pmts-result.txt). So I copy the results from the web page, past it to a text file and then clean it up removing all the "junk" not needed. As such is there a way I can read the first text file (ee-online-pmts.txt) and then have a list of variables to parse that if found would be removed in such a way that the result will be what the 2nd text file looks like? For instance if  "Print this activity" and two carriage returns (enter, enter) are found it will remove it? Thanks!
ee-online-pmts.txt
ee-online-pmts-result.txt
0
This macro lists the number of items next to each item when clicking on the top row of a column.

I 'think' this macro may depend on a function and on sheet level code.

I'd like to make it work as a single macro if possible.

Assistance is greatly appreciated.
mListbox.xlsb
0
I am currently trying to enforce a password policy with a minimum of 8-10 characters, a capital, number, and symbol.  Typically I use a regex in asp.net, however I am trying to do this for a classic asp site prior to form submission.  I was hoping to find something that would pop up when it doesn't match the criteria or something where it starts with a disabled "Submit" button and once you hit the criteria the button would become "active".

The only thing I have working now is:
If  Len(Request("password")) < 6 Then
	ErrorMessage = ErrorMessage & Server.URLEncode("You need to enter a Password of at least 6? characters.\n\n")
End IF

Open in new window

which makes the user have 5 or more characters in their password.
0
We currently operate within a Citrix environment and publish a number of web applications by point to Internet Explorer with the corresponding website as the parameter.

We face an issue currently whereby if the browser is closed, the session remains active.

We need the session to logoff if the browser is closed.

With a previous version of IE (8 perhaps, but not entirely sure) we scripted this, however in current versions of IE this no longer works.

I guess a script that launches IE, and then monitors for its closure before issuing a logoff command would be ideal, but am open to alternative suggestions if there are better ways to achieve what we are looking for.
0
Im trying to read only first letters of each in the given sentence

Example  "Hello World"

i want out put as this : HW
Please help
0
Dears,

I am trying to sort the texts of one particular node (<Name>) of a XML file in ascending order using VB Scripting.

Say, I am using a XML file (xyz.xml) with content as shown below:

<?xml version="1.0" encoding="utf-8"?>
<!--Informations Vendor="Country S.A."-->
<India>
      <Statelist>
            <Name>2122</Name>
            <Name>1011</Name>
            <Name>Karnataka</Name>
            <Name>Goa</Name>
            <Name>Assam</Name>
      </Statelist>
</India>

The expected output is:

<?xml version="1.0" encoding="utf-8"?>
<!--Informations Vendor="Country S.A."-->
<India>
      <Statelist>
            <Name>1011</Name>
            <Name>2122</Name>
                <Name>Assam</Name>
            <Name>Goa</Name>
            <Name>Karnataka</Name>            
      </Statelist>
</India>

Can someone please help me here?

Best regards
Chethan Bangera
0
Hi All,

I have another file which needs reading and converted to CSV.

I have attached the file and sample needed , anyhelp is appreciated.

Thank you

A
AP070717.txt
APSAMPLE.xlsx
0
I am new to excel vbscript.
I have XLSM file spreadsheet called A.xlsm that contains macros written in it.  I am trying to read this A.xlsm file from another xlsm file but this seems not working.

Please help.

Thanks in advance.

Srini
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 experts, I think there's a short cut method in reading text file. My code below looks so messy and I want to modify it in a clean and short way. My goal is to read all text files (Sales.text) since when the user add the sales it would rename to Sales (1).txt , Sales (2).txt and so on. Any help please.

Private Sub Command2_Click()
    Dim iPath As String
    Dim FileSystemObject As Object
    
    Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
    '1
    If FileSystemObject.FileExists("C:\Users\Administrator\Downloads\Sales.txt") Then
        iPath = "C:\Users\Administrator\Downloads\Sales.txt"
        doPrinting iPath
        FileSystemObject.DeleteFile iPath
    End If
    '2
    If FileSystemObject.FileExists("C:\Users\Administrator\Downloads\Sales (1).txt") Then
        iPath = "C:\Users\Administrator\Downloads\Sales (1).txt"
        doPrinting iPath
        FileSystemObject.DeleteFile iPath
    End If
    '3
    If FileSystemObject.FileExists("C:\Users\Administrator\Downloads\Sales (2).txt") Then
        iPath = "C:\Users\Administrator\Downloads\Sales (2).txt"
        doPrinting iPath
        FileSystemObject.DeleteFile iPath
    End If
    '4
    If FileSystemObject.FileExists("C:\Users\Administrator\Downloads\Sales (3).txt") Then
        iPath = "C:\Users\Administrator\Downloads\Sales (3).txt"
        doPrinting iPath
        FileSystemObject.DeleteFile iPath
    End If
    '5
    If 

Open in new window

0
Hi experts, I wish to know how to get the Hard Drive serial no on my pc using vb6, not the drive c or d, but the hardisk itself who's serial number is found at the back of the Hardisk itself. Any help please!
0
Hi All,

I have a ".exe" file which need to be executed for every 3 hours.
So, i want to automate the process. while doing so i need to click a button through the VB Script.

After execution, the .exe file will display so many options.
Out of them, i need to click "Import" button, which will come after three tabs of opening the exe file.

Below is my code.

Set oShell = CreateObject("WScript.Shell")
      oShell.Run("C:\setup.exe")
      oShell.AppActivate ("C:\setup.exe")
      oShell.SendKeys "{tab}"
      oShell.SendKeys "{tab}"
      oShell.SendKeys "{tab}"
       oShell.SendKeys "{ENTER}"

I Am running the above script from the command prompt.
After the execution the script is opening the application, but staying there without doing any action.

Could any one please let me know, if there is any way to click the import button.
Thanks in advance.

Thank You.
0
I had this question after viewing C++ COM Method with Optional Arguments.

I am trying to produce a COM object in Visual C++, where one of the methods accepts optional arguments. Below are the interface declaration, the class implementing the interface, and the implementation of the method taking an optional argument. As it stands, it compiles. But when I try to call the function from an ASP page using VBS with the supposedly optional parameter missing, I get the following error


Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment: comObject.ShowFinalSql

Following code in IDL
interface IWPharma : IDispatch{
   [id(2), helpstring("method ShowFinalSql")] HRESULT ShowFinalSql([in] BSTR query, [in] BSTR cleanup);

in C++:
    STDMETHOD(ShowFinalSql)(BSTR query, BSTR cleanup) override

in VB with error:
SET comObject = CreateObject("WPharma.Main")

REM Тест #1
comObject.ShowFinalSql "CHECK_SIGNATURES 01/01/2017", ""
0
dear sir
please share vb script to export users from AD with detail of creation and path of Users
0
I am trying to create a batch/vbs script to:
- launch an Internet Explorer session
- goto a specific URL
- login.

I got this script:
WScript.Quit Main

Function Main
  Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
  IE.Visible = True
  IE.Navigate "http://xxx.xxx.xxx.xxx:808/doc/page/login.asp"
  Wait IE
  With IE.Document
    .getElementByID("loginUserName").value = "zzz"
    .getElementByID("loginPassword").value = "zzzzzz"
    .getElementsByName("loginbg")(0).Submit
  End With
End Function

Sub Wait(IE)
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy
End Sub

That starts the process OK but once the credentials are entered, the user ID gets erased and I get this error:
script:  
line: 11
char: 5
Error: Object required: 'getElementsByName (....)(...)'
code: 800A01A8

Please advise how to fix it.
0
How to handle Special characters like(., etc) while verifying the mobile number

Ex: 9.849955144 is not a valid mobile number how to handle this type of situations

Dim val
val=InputBox("Enter Value")
If IsNumeric(val)=true Then
      If Len(val)=10 Then
            If left(val,1)=9 or left(val,1)=8 Then
                  MsgBox "val is a valid mobile Number"
                  Else
                  MsgBox "Value is invalid mobile Number"
            End If
            Else
            msgbox "Input value contains lessthan 10 numbers invalid input"
      End If
      Else
      msgbox "It is not a numeric value"
End If
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
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
[Webinar] How Hackers Steal Your Credentials
LVL 9
[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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
Hello.
I have a VBScript, which could define a computer IP address, using a website. After sometimes the website turned off this possibility.
Please, can you change this script to make it workable? No matter what website will be used.

Const cstrShowMyIP = "http://ip2country.sourceforge.net/ip2c.php?format=XML"
On error resume next

Dim objRemXML
Dim objMyIP
Dim strIPAddress
Dim strHostname
Dim strCountry
Dim strCountryCode
 
Set objRemXML = CreateObject("Microsoft.XMLDOM")
objRemXML.async = False
objRemXML.Load (cstrShowMyIP)
If Err.Number <> 0 Then
   MsgBox "Error of ip address from " & cstrShowMyIP
   WScript.Quit
End If
 
' Get your IP address
Set objMyIP = objRemXML.selectSingleNode("/lookup/ip")

If Err.Number <> 0 Then
   MsgBox "Error of ip address"
   WScript.Quit
Else
   strIPAddress = objMyIP.Text
End If
 
' Get your hostname
Set objMyIP = objRemXML.selectSingleNode("/lookup/hostname")
If Err.Number <> 0 Then
   MsgBox "Error of ip address"
Else
   strHostname = objMyIP.Text
End If

' Get your Country
Set objMyIP = objRemXML.selectSingleNode("/lookup/country_name")
If Err.Number <> 0 Then
   MsgBox "Error of Country"
Else
   strCountry = objMyIP.Text
End If

' Get your Country
Set objMyIP = objRemXML.selectSingleNode("/lookup/country_code")
If Err.Number <> 0 Then
   MsgBox "Error of Country Code"
Else
   strCountryCode = objMyIP.Text
End If


' Print info
MsgBox " your ip address : " & strIPAddress,,"   …
0
Hello,

I'm aware that various parts of an Excel window (eg gridlines, headings, Formula bar, etc) can be hidden using the View menu and other parts (sheet tabs, scrollbars, etc) can be hidden by going to: File > Options > Advanced.

Recently I came across a thread in Mr. Excel which includes a post (by none other than prolific EE expert Rory Archibald) showing VBA code for how to display the Status Bar in Excel:

application.DisplayStatusBar = True

Open in new window

I actually wanted to hide the Status Bar so I inserted:

application.DisplayStatusBar = False

Open in new window

which worked.

Now I'm wondering what other parts of an Excel (or other app) window can also be hidden using VBA. For example, is it possible to hide the Title bar, Ribbon and/or Quick Access Toolbar in a similar way? If so, can someone post the code?

Thanks
0
I am using vb script for installing an application the before that it has to uninstall older versions...Problem is that it's installing but not uninstalling the older version
0
i need your help to solve my problems. i have a workbook which contains three worksheet name called ( Alpha, Bravo,Charlie) and each worksheet there is a chart and i display all the chart in one worksheet called All in one sheet. Now what i need i need to run the chart as animate of whole year data value or selecting by months wise. if i click button start and stop the chart should run as Animate of whole year.


i attached my file for our reference and video look here

sample file i am attaching please help me it will be great appreciate to me .

i have to animate in worksheet name called ( All chart in one)
2. sample file i attached same like i need to run the chart please...... help me.

if you need any additional details please let me know you can modify the chart as you like of best appearance.
ALL-CHART-IN-ONE-rev1.xlsm
Graphic-animation--1-.xlsm
Expand-Chart-Selection.xlsb
0
is it possible to programatically create a computer to computer voice chat using classic vb or vb.net through internet?

e.g. suppose two computers A in UK and B in USA
computer A is a server  which is connected to a client computer B
at the same time
computer B is a server  which is connected to a client computer A

the user on Computer A Sayes: hellow
    1- the sound is converted to a file (..wav)
    2- the wav file is immediatly sent to computer B winsock
    3- Computer B winsock recieves and play the voice
the user on Computer B Sayes: How Can I help
    1- the sound is converted to a file (..wav)
    2- the file is immediatly send to computer A winsock
    3- Computer A winsock recieves and play the voice
and so on

Because both are servers and clients at the same time then they can both talk at the same time and also listen.

or may be there is a tool better that winsock that does the job, open channel and deal with the voice .....
0

VB Script

36K

Solutions

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.