We help IT Professionals succeed at work.

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 want to take some action if any of three changes occur in an excel spreadsheet. I have written some vb code, examples attached. If the first condition which is a change to staff number is made, the code works fine. If the 3rd  condition where the absence type changes, it also works fine. No matter what I do with the 2nd condition it does not work. I have tried recoding with what elseif's, I thought maybe because the column is a calculated field it didn't like it, so tried it instead on one of the date columns. I have even moved the conditions around. But no matter what I do only the absence type or the staff no changes will behave as I expect. I have attached the workbook and the troublesome code. In the workbook what should happen is that when a new absence is entered on the absence sheet, then the number of sick days for that employee should be recalculated on the PR sheet. If the row has been entered a with an incorrect date or an incorrect absence type the change should prompt a  recount of the total number of sick days for the employee.
sample-for-EE.xlsm
code-snippet.JPG
0
Hi,

I need to convert this html file attached to classic asp. Please advise how I go about doing so. Thankyou.
sample.txt
0
Hello, i'm trying to learn the basics of VB.
I have installed Visual Studio 2019
I have installed MySQL server and created a test db with a table and column.
I have connected the studio to MySQL successfully
I'd like to master creating a form and inserting, updating and displaying the contents of the db table.

I'm struggling to find a decent video tutorial of this. like how to program the save button and insert it into the db.

All the videos i find are either in very bad English or they describe very different methods from each other so i'm not sure which one i should be following.

can someone point me towards some good material please?
thanks
zac
0
Hello again Experts,

Attached is sheet that contains more date but as a preview some lines are quoted below....
I have used Excels 'weekday' formula,  but I need if 1->7 (Monday through Sunday) then translate as "everyday", if 1->5 (Monday through Friday) then translate as '"Mon-Fri", where there's only 3 translae as Wednesday, etc.



SESSION_NAME      PROCESSING_DATE      day number      cycle name

ACDC0010      23-12-2019      1      
ACDC0010      24-12-2019      2      
ACDC0010      25-12-2019      3      
ACDC0010      26-12-2019      4      
ACDC0010      27-12-2019      5      
ACDC0010      28-12-2019      6      
ACDC0010      29-12-2019      7      everyday
ACDC0010      30-12-2019      1      
ACDC0010      31-12-2019      2      
ACDC0010      01-01-2020      3      
ACDC0010      02-01-2020      4      
ACDC0010      03-01-2020      5      
ACDC0010      04-01-2020      6      
ACDC0010      05-01-2020      7      everyday
ACDC0010      06-01-2020      1      
ACDC0010      07-01-2020      2      
ACDC0010      08-01-2020      3      
ACDC0010      09-01-2020      4      
ACDC0010      10-01-2020      5      
ACDC0010      11-01-2020      6      
ACDC0010      12-01-2020      7      everyday
ACTU0010      06-01-2020      1      
ACTU0010      07-01-2020      2      
ACTU0010      08-01-2020      3      
ACTU0010      09-01-2020      4      
ACTU0010      10-01-2020      5      mon-fri

I hope it's clear and not too hard to achieve this, it would be great help for me.
Thanks in advance
sesprocdate.xlsx
0
Hello experts,

I have multiple svg files in SourceFolder, I am looking for an script to save them to TargetFolder with a new extension .jpg

Requirements:
-Be able to report as parameter SourceExtension, TargetExtension, SourceFolder, TargetFolder, LogFile.
-Log the various that have been save to new extension.

If you have questions, please contact me.
0
this is a VBscript  How do I convert the xml response to a text file without the tagnames?

Dim xml : xml = PostURL(HRP_BaseDomain & path, values)

Dim oXMLDoc, oXMLHTTP, oXMLResults, oXMLFields
Function PostURL(path, values)
   LogItem "path: " & HRP_BaseDomain & "   " &  path : LogError : Err.Clear
   On Error Resume Next
   set oXMLHTTP = createobject ("MSXML2.XMLHTTP.6.0")
   oXMLHTTP.open "POST", path, false
   oXMLHTTP.setRequestHeader "Content-type","application/x-www-form-urlencoded"
  oXMLHTTP.send values
   LogError : Err.Clear
   PostURL = oXMLHTTP.responseText
End Function

Open in new window

0
I'm trying to call a MySQL stored procedure and read its out parameter using ASP classic. Unfortunately I get the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[MySQL][ODBC 3.51 Driver][mysqld-5.5.5-10.3.17-MariaDB]OUT or INOUT argument 2 for routine baseline.Proc_Test is not a variable or NEW pseudo-variable in BEFORE trigger
/functions/command_procedure.asp, line 54


The stored procedure is defined here:

DELIMITER //
CREATE PROCEDURE Proc_Test (IN  Lang_param  VARCHAR(10),
                            OUT ID_param    int)
BEGIN
   SET ID_param = 99;
END //
DELIMITER ;

CALL Proc_Test ('eS', @myID);
SELECT @myID;

Open in new window


Here is the ASP classic script calling the stored procedure:

<%@ Language=VBScript %>
<%
    Option Explicit
    Response.Buffer = True
    Dim Hostname, Username, Password, Database
    Hostname = "localhost"
    Username = "baseline-user"
    Password = "xxxxxx"
    Database = "baseline"
    
%>
<html>

<head>
<title>Baseline Connection</title>
<style type="text/css">body {font: normal 11px Arial}</style>
</head>

<body>

<%
   Const adCmdStoredProc = 4
   Const adParamInput = 1
   Const adParamOutput = 2
   Const adInteger = 3
   Const adVarChar = 200

   Dim Command
   Dim Connection
   Dim ConnectionString

   Dim myLang
   Dim myID

   Set Connection = Server.CreateObject("ADODB.Connection")
   ConnectionString = _
     "DRIVER={MySQL ODBC 3.51 Driver};" & _
     "SERVER=" & Hostname & ";" & _

Open in new window

0
Running Windows 7 Professional SP-1, I have a VB Script which executes when my POP Email checker detects an incoming message with certain characteristics.  The Script launches an Internet Explorer banner on the desktop, and sends me an Email.  This has worked for the past three years, until today, when the banner stopped appearing, and an error message appeared on the desktop.  I'm unaware of any changes to my system which explain this.  I am not the author of this script, am entirely uneducated about its code, and I'll need specific guidance about how to correct the issue.  A confusing aspect of this is that the same script works on my other computers, with no error.

Here is the error message and the pertinent part of the script code...   Thank you in advance!

Error message
Option Explicit
Dim objIE, objShell, k, strIETitle, blnFlag

' Set IE display box title. Dashes ("-") are to move the Microsoft title
' appended to the title we specify out of view.
' blnFlag is set to False when the user closes the IE display box.
strIETitle = "On-Line Booking Advice has arrived in POP3 Mailbox" & String(40, "-")
blnFlag = True

Set objShell = CreateObject("WScript.Shell")

' Initialize display box with initial message
InitIE "<CENTER><B><FONT COLOR=WHITE>Reservation at Maui Tradewinds!</B></FONT></CENTER>"


Sub InitIE(ByVal strMsg)
    ' Subroutine to initialize the IE display box and display it on top of any other active windows.
    Dim intWidth, intHeight, 

Open in new window

0
I have written VBScript code to look for specific files in a folder and when the code finds the files the code will move the files to another folder.  I am able to find one file and move it, but when I try to find two or more files I get the "Expected end of statement" error.  I have included the code that I have written.  

Dim objFSO
Dim sSourceFolder
Dim sDestFolder
Dim sDBFile
Dim sDateTimeStamp
'Const OVER_WRITE_FILES = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
sSourceFolder = "C:\Oceanside\"
sBackupFolder = "C:\Files_Found\"
sDBFile = "ROWP19-0578 PERMIT","ROWP19-0579 PERMIT"  'Expected end of statement error on this line when I try to search for two files
sDBFileExt = "pdf"
 
'If the backup folder doesn't exist, create it.
If Not objFSO.FolderExists(sBackupFolder) Then
    objFSO.CreateFolder(sBackupFolder)
End If
 
'Copy the file as long as the file can be found
If objFSO.FileExists(sSourceFolder & "\" & sDBFile & "." & sDBFileExt) Then
    objFSO.CopyFile sSourceFolder & "\" & sDBFile & "." & sDBFileExt,_
			sBackupFolder & "\" & sDBFile & "." & sDBFileExt
MsgBox sSourceFolder & " was copied to " & sBackupFolder
End if
 
Set objFSO = Nothing

Open in new window

Any help is greatly appreciated.
0
Hi,

Got great help recently with a Word Macro!

Does EXACTLY what I needed. :D!

Want to know if there's any way to add a feature to it.

This Macro allows me to search for a specific style.  Once found the Macro will focus the screen to the last character of the text.  So that, when you run the search, you may see at the top of your screen:

the force is impressed.

While the full lines of the styled text may be

The alteration of motion is ever proportional
to the motive force impressed and is made
it in direction of the right line in
which the force is impressed.


with

The alteration of motion is ever proportional
to the motive force impressed and is made
it in direction of the right line in


not visible just beyond the upper edge of the screen.

Is there any way to have the macro execute the searches BUT...to add a line or two BEFORE the point of the find?

Put another way, add a bit of space that appears before the found text block that has the style?

Sub aaai_JumpToStyle_Fwd()
On Error GoTo ErrorHandler
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("chrAComms")
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindAsk
        .Format = True
        .MatchCase = False
        

Open in new window

0
I've got a style that I do lots of commenting in.  

Microsoft Word has got a search by style built-in, but it's pretty clunky.

Is there any way to modify this Macro to have it search for a named style?

The style name I'm using is

chrAComms

And it is a character style.

Sub aaag_HeaderDown()
On Error GoTo ErrorHandler
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToNext, Count:=1, Name:=""
ErrorHandler:
End Sub

Sub aaah_HeaderUp()
On Error GoTo ErrorHandler
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToPrevious, Count:=1, Name:=""
ErrorHandler:
End Sub

Open in new window


My thinking here is that f I can get a Macro to run the style search, I can set two keyboard shoorcuts and blaze through to the comments I need to see.

Many thanks!!

OT
0
Microsoft Word VBA or VB Script
Find specific text and replace with a Bookmark by the name in the text

arrTextVals = Array("Text1","Text2","Text3"... "Text130")

for each tval in arrTextVals

    'question is how to code the following:
     worddoc.find(tval).replace(Add Bookmark(teal))

next
0
Is there a maximum amount of data that winsock will send to a text file?  I am using a vb6 program to send data to my PC from an external race timing device and it routinely fails at about 330-350 records.  I will include a sample below.  If so, is there a way I can increase this limit?  If you need to see a sample of my code I can provide that.  It is code that I got on this site and modified to fit my needs.

Note that when I do the same thing with Putty there is no issue but I don't want to have to open Putty to do this.  I want to do it via my vb program.  (I have another post open right now on how to save the Putty output to a text file on my machine.  Either of these options would work for me...)

Sample data being streamed:
aaC5000000019ba4000119112809452862c4FS
aaC5000000019ba400021911280945290ff4BS
aaC6000000019ba4000219112809452912c2LS
aaC700000001a00700011911280945364dbdFS
aaC700000001a00700041911280945370891BS
aaC700000001a00700041911280945371791LS
aaC4000000019dcf000119112809464113f1FS
aaC4000000019dcf000219112809464113f2BS
aaC5000000019dcf000219112809464126f7LS
aaC4000000019b160001191128094707599aFS
aaC4000000019b160001191128094707599aBS
aaC4000000019b1600021911280947081493LS
aaC4000000019da4000119112809472041bcFS
aaC4000000019da4000219112809472050bdBS
aaC5000000019da4000219112809472053c1LS
aaC5000000019d4000011911280947313793FS
aaC5000000019d4000041911280947315bc3BS
aaC7000000019d4000041911280947320fc5LS
0
Hi fellow Experts and members,

I would like to create a VB Script for my daily data entry from Excel to AS400 but I have little non programming knowledge.

I have attached a screen shot of a screen which I have to input on a daily basis and highlighted yellow are the fields that I have to input. After inputting all the required filed then I will have to press F2 to screen, and then Ctrl P to print screen the page.

As of now I have created a very simplified VBA script (not VB and from Excel) to just copy paste from excel to AS400 but sadly this is not a feasible method as it does not detect if the AS400 screen is ready for a input nor does it check if there is any error at AS400.

My ultimate goal is to actually create a VB Script to run from AS400 that can do the following:
1. check if the row is keyed in from Excel to AS400 and return a value/remark to Excel that it is keyed
2. Have a pop out screen to show the status how many is completed
3. display any error if certain rows or value are not able to be keyed

A sample of this will be similar to this that I have found on youtube - https://www.youtube.com/watch?v=rryB3GN48t8 

If any one is willing to share your knowledge or to create a sample for me to reference will be greatly appreciate! Will definitely pay for it if I have to as this will greatly assist with my workload!
data-entry-page.PNG
Book1.xls
0
I'm trying to get each line or row of output I get from a command into a seperate variable.
I'm defining a variable from this command I'm running (function listed below):
$PKGID = CM -Computername computer1 | Where-Object SuccessOrFailureCode -ne 0 | Select-Object packageid -ExpandProperty packageid
Write-output "$PKGID"

Open in new window

For example, if I only get one hit or SuccessOrFailureCode -ne 0, the output I get is:
1000
If I get two or more hits, the output can look like:
1001
1002
1003
I am then using this $PKGID variable in another function to trigger an install.
This only works when I have one hit, when I have more than one, the $PKGID variable encapsulates all of them and I cannot use.

Is there a way to get the output of each row into a seperate variable?  Example:
$PKGID would = 1000
$PKGID1 would = 1001
$PKGID2 would = 1002

This is the function I'm calling this from:

Function CM {

[CmdletBinding()]
Param
(
      [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true,ValueFromPipeline=$true)]
[string[]]$ComputerName = $env:COMPUTERNAME
)

Begin
{

$Code = {
# Get Execution History from registry, and package details from WMI
$ExecutionHistoryKey = "HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Software     Distribution\Execution History" 
$ContextKeys = Get-ChildItem $ExecutionHistoryKey | Select -ExpandProperty PSChildName
foreach ($ContextKey in $ContextKeys)
{
    If ($ContextKey -eq "System")
    {
        $ContextKey = 

Open in new window

0
I need to create a dialog in vb6 that will pass some parameters to Putty.  As I understand it, this can be done via Putty's command line capability.  Can I get some guidance on how accomplish this?  I can write the vb.  I just don't know how to pass the parameters to an external program like Putty.

Thanks in advance!
0
Hi Experts,

I'm using Visual Studio Code.

I saw this cool extension:

Copy With Line Numbers
https://marketplace.visualstudio.com/items?itemName=yassh.copy-with-line-numbers&ssr=false#qna

The extension website menu shows that i will see a menu like this.

p1.PNG
But after I installed the extension, When I open up a C# or VB file I don't see that menu circled in red.

When I select all the code and right click the mouse button I just see this menu.
This copy, on this menu just a regular copy, it doesn't copy the line numbers.

p2.PNG



How do I launch that menu circled in red in the screenshot above, so I can copy code with line numbers using this extension?
Is their some keyboard shortcut keys I can use to copy?
0
Hello Experts,
I am required to execute a batch script which starts or stops a service on Windows Server 2012 machine. I however do not want the UAC window asking for admin privileges to pop-up, as I am actually invoking the batch execute from another application in an automated fashion. While I do have admin rights on the machine, it restricts me from accessing the registry or the Task Scheduler.

Can I please know if there is a way out?
1
I would like to modify the attached output.xlsx file.

Regardless of how many lines it has I would always like to add a Totals line at the bottom and total the following columns.

Tot PC Qty

Code 1 Qty

Code 2 Qty

Code 3 Qty

Full P

Part P

Part P on G

Stand PU

C PU

Extra C PU

Extra Stnd PU

I would like to accomplish this by using an external script.
output.xlsx
0
Hi all,
Please I would really appreciate your help here.
I have attached the sample excel file with sample 17 rows added (on 'Add Rows' tab) for 1st row in tab 'Source Data'. I need a macro that basically inserts 17 data rows on tab:'Add Rows' based on every 1 data row added on tab: 'Source Data'. Header Data remains same on tab 'Add Rows'.

For the 17 rows added on tab 'Add Rows' I need below values:
(1) Column 'Item Number': Same value as B2 (tab Source Data) appearing 17 times.
(2) Column Attribute Name: Same values as example provided (from Parent ID to Price Quantity)
(3) Column Attribute Value:
- C6 (Extended Price): $ sign + same value as H2 from 'Source Data' + AUD
- C7 (Item Category): Standard (remains same does not change)
- C8 (Material Group): relevant value from C2:C15 (tab: Material Groups) depending upon M2 in tab Source Data.
- C14 (Supplier Part ID): same as F2 from tab 'Source Data'.
(3) Column Display Text: Same values as example provided (from Parent ID to Price Quantity)
(4) Column Type: Same values as example provided (from Text (single line limited) to Whole Number)
(5) Column Description: Same value as B2 (tab Source Data) appearing 17 times.
(6) Column Is Term added from Item Master: 'No' appearing 17 times
(7) Column Formula: Blanks 17 times

Many thanks!
Expert-Exchange_Template.xlsx
0
Working in VB/VBA, I have a window handle and I need to convert it to a window object/instance which I can use to access the window object's properties.

AccessibleObjectFromWindow has not proven useful.

How do I do this?
0
C:\Folder\Output.txt

The text always has values next to the group of words below.  (Some numberic values have been entered to show an example:

Total Stnd PU: 19
Total C PU: 12
Total Extra Stnd PU: 2
Total Extra C PU: 2
Total P:


I would like to run a script against this Output.txt so that the script looks far numeric values at the end of each of:

Total Stnd PU:

Total C PU:

Total Extra Stnd:

Total Extra C Pu:

I would like the script to look to the right of these words and add all the values and then put the value after the words:

Total P:  

So after the script runs, the file should be resaved and it should look like this;


Total Stnd PU: 19
Total C PU: 12
Total Extra Stnd PU: 2
Total Extra C PU: 2
Total P: 35

Thanks in advance for your assistance.
0
So I have a control file that opens a file and want to change the value in the sheets.
0
Hello, I have the following script for a google sheets. I would like the row of data to be copied down to the next available (empty) row and then the original data to be cleared, ready for the the next input.

function saveButton() {
  var ss = SpreadsheetApp.getActive();
  // [START modifiable parameters]
  var sourceRange = ss.getRange('Active Jobs!A2:F2');
  var targetRange = ss.getRange('Active Jobs!A3:F3');
  // [END modifiable parameters]
  sourceRange.copyTo(targetRange);
  ss.toast('Data copied to ' + targetRange.getSheet().getName() + '. ' +
    'To undo, press Control+Z (on a Mac, ⌘Z).', 'Action button - Save');

  var ss = SpreadsheetApp.getActive();
  // [START modifiable parameters]
  var rangeToClear = ss.getRange('Active Jobs!A2:F2');
  // [END modifiable parameters]
  rangeToClear.clearContent();
  ss.toast("Cleared range '" + rangeToClear.getSheet().getName() + "'!" + rangeToClear.getA1Notation() + '. ' +
    'To undo, press Control+Z (on a Mac, ⌘Z).', 'Action button - Clear');
  rangeToClear.activate();
}

Open in new window



I have two problems:

1, var targetRange = ss.getRange('Active Jobs!A3:F3');

this line needs to read... in plain english..... find the last available row and insert



2, The delete does not seem to clear the last visited cell. So the last cell that the user inputs into is F2. If the user does not click out of that cell before pressing save then this cell is ignored.

thanks for your help.

https://docs.google.com/spreadsheets/d/1qSauIqjvSEhEEZJ6z4pJUnR_HZcoMi98frAx94zl6a8/edit?usp=sharing
0
I need to automate a task in Outlook.

I need a button in an email form to open an email in a new forwarding form, change the From: field to another account and add a particular address in the To: field then send the message. This will change a 6 click & 1 keystrake operation into 1 click.

I expect this can be done with VB code assigned to a custom button the the ribbon or the Quick Access Toolbar

Thanks in advance
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.