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.

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

Sign up to Post

I had this question after viewing Random hours in timesheet.

As a complete newbie to VBA I followed the exact instructions provided in the quoted post. My problem is really really similar with a view exceptions. I need to work with Integers only and without specific percentages, rather Total hours per project as input values, which suppose to be randomly distributed across workdays respecting total hrs per day allowed by the employer on a specific day (example attached). So the bottom row is a manual input as well.
Timesheet Example
I started first to make the already proposed solution running. I made the following changes to the original script (disclaimer: working on Mac):
  • deleted all CDec() comands and replaced with simple natural numbers, since I need Integers only
  • replaced Scripting.Dictionary with another one since in VBA 2019 on Mac there is no "Microsoft Scripting Runtime". (Found a replacement also online that seems to work)

But having two issues:
While compiling a VBA Project there seem to be no mistakes or anything. But upon runtime in a single cell it says "Object doesn't support this property or method"
But in general I am assuming I am missing some ground knowledge. How do I run this macro across my cells? How do I provide input. What if I need to add 5 or 8 customers. Where do I input target hours per customer. Or how can I expand it to a whole month. So where is the input and output if I may say it like this.

Thanks in advance for any help.
0
Array VB Script breaks if you change the hostnames, unable to modify.

arrFolders = Array( _
        "\\cgex01.sunlife.loc\c$\Program Files\RightFax\RFaxGate\;*.tmp", _
	"\\cgex01.sunlife.loc\c$\Program Files\RightFax\RFaxGate\;*.tiff", _
	"\\cgex01.sunlife.loc\c$\Program Files\RightFax\RFaxGate\;*.PDF", _
	"\\cgex01.sunlife.loc\c$\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Pickup\", _
	"\\cgex01.sunlife.loc\c$\Program Files\Microsoft\Exchange Server\V14\RightFax Exchange Connector CGEX01\" _
        )
 
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strBlatPath = "Blat.exe"
strServer = "mail.server.org"
strTo = "server.admins@server.org"
strFrom = "SunLife.RightFaxToExchange@server.org"
strSubject = "Rightfax Email Connector, Orphaned files found in Directories" 
intFolder = 1
For Each strFolder In arrFolders
	strBody = "Please see below the folder details:"
    intCount = -1
    strFolderSpec = ""
    strFileSpec = ""
    If InStr(strFolder, ";") > 0 Then
        strFolderSpec = Split(strFolder, ";")(0)
        strFileSpec = Split(strFolder, ";")(1)
    Else
        strFolderSpec = strFolder
        strFileSpec = Null
    End If
    intCount = CountFiles(strFolderSpec, strFileSpec)
    If strFileSpec <> "" Then
        strBody = strBody & vbCrLf & strFolderSpec & " has " & intCount & " " & strFileSpec & " files in it."
    Else
        strBody = strBody & vbCrLf & strFolderSpec & " has " & 

Open in new window

0
When I open and read emails in Outlook O365 (desktop) with zoom set to 100%, it's too small. I'd like the zoom to be permanently set to 120%. Currently it's 100% and apparently resets back to 100% even after I change it. It's too small and the text is difficult to read.
I'd like VBA code so that whenever I enter Outlook, my magnification is set to 120%.
Whenever I open an email, my magnification is set to 120%
0
I have narrow it down to a cell in a WebTable, now all I want to do is get the url that is there if I click on it.  Any ideas?

TryingToGetURLToLinkInThisWebTableCell = Browser("MyBroswer").Page("MyPage").WebTable("WebTable").GetCellData(3,3)

This returns a name, instead of the link.  In was trying to force it to SetFocus, and then something like GetROProperties("url") but not sure how to fit that in.
0
I have purchased hosting package on Godaddy server, I have added one domain there, now I want to run my Asp.net website pages there, I am using asp.net with vb website 3.5/4.0, Can
I setup that on Godaddy, I saw there is plex admin, Please help me to setup my website there.
0
I need a Visual Basic script that will copy a text file to a PDF file.
0
Are there any VBA (or VB or VB.Net) code samples for submitting Payment Request to PayTrace.  This is strictly a desktop app.  We are switching from one payment processor to PayTrace for our Access app.  We have functioning module for other processor but could use some samples in VBA for PayTrace.  PayTrace seems mainly designed for Web Forms but should be doable from desktop,
0
Hello Experts,

I am being prompted when doing mailmerge with word, "select * from Maildata prompts" and wondering if there is a VB script that can suppress the prompts while the program is running.  Microsoft workaround is to make a registry change but it comes with a big caveat.

Thanks in advance.

Silver
0
VB application that sends PowerShell commands and receives the output.

I am putting the output in to a List view.

The following works fine:

 
[code]      For Each ID In PSOut

            i = i + 1

            'Dim str(6) As String
            Dim str(ColumnCount) As String
            Dim ItCount As Integer = 0
            Dim itm As ListViewItem

            '     Do While ItCount < ColumnCount
            For Each strHeadDSingle In strHeadD2
                str(ItCount) = ID.Properties("name").Value.ToString() ' ### WORKS FINE
                ItCount = ItCount + 1
            Next
            '    Loop
            '         Name, SamAccountName, EmailAddress, PrimarySMTPAddress, UserPrincipalName, DistinguishedName, Enabled"

            itm = New ListViewItem(str)
            ListView1.Items.Insert(0, itm)
        Next

Open in new window

[/code]


When passed as a variable I get the following:

  For Each ID In PSOut

            i = i + 1

            'Dim str(6) As String
            Dim str(ColumnCount) As String
            Dim ItCount As Integer = 0
            Dim itm As ListViewItem

            '     Do While ItCount < ColumnCount
            For Each strHeadDSingle In strHeadD2
                str(ItCount) = ID.Properties(strHeadDSingle).Value.ToString()          ' ### ERRORS THIS LINE
                ItCount = ItCount + 1
            Next
            '    Loop
            '         Name, SamAccountName, EmailAddress, PrimarySMTPAddress, UserPrincipalName, DistinguishedName, Enabled"

            itm = New ListViewItem(str)
            ListView1.Items.Insert(0, itm)
        Next

Open in new window

     


it works 100% as a stated item.

When I try to make my reusable code I get the following on this line when debugging:

System.NullReferenceException
Object reference not set to an instance of an object.

I have checked and values are there quite happily... but little confused.,

Please advise

Many thanks in advance

R
0
Dear All;

See if you help to make the below code work in VBA , its a VB code used to calculate the CRC or Cheksum , I have been battling with it for pas 24 hours but no solution. The CRC will called  from a module  so  like its name CRC

For example it must handle the calculation like CRC(Header1&Header2&Cmd1&Length&Content) for serial port :

VBA Code before amendments:

Option Compare Database
Option Explicit

Public Function calculateCRC8(ByVal AppID As String) As String
    Dim CRC8 As Byte
    Dim i As Integer
    Dim J As Integer
    Dim AppIDarray() As Byte  '<--- explicitly dimensioned as a Byte array to avoid confusion
    Dim aidLength As Long

    CRC8 = &HC7

    'The AppID is actually bytes stored in hexadecimal in a string. You have to convert them back to bytes before you can run a crc8 on them.
    AppIDarray = HexToByte(AppID)
    aidLength = UBound(AppIDarray)
            For J = 0 To aidLength
                CRC8 = CRC8 Xor AppIDarray(J)
                For i = 1 To 8
                    If CRC8 And &H80 Then
                     'masking off the left-most bit before shifting prevents the Overflow error.
                     CRC8 = ((&H7F And CRC8) * 2) Xor &H1D
                    Else
                     CRC8 = CRC8 * 2
                    End If
                Next i
            Next J
    calculateCRC8 = CRC8
End Function
Public Function HexToByte(strHex As String) As Byte()
    Dim i As Integer
    Dim tempByte As Byte
    Dim 

Open in new window

0
Hi,  
Had a question on Power BI, and the adding/creating a custom notes/text form or box within the report/visualizations.  

The note feature in PowerBI, although i think is great is not what user wants.  The note form will also need to be written back to db/table and when user opens the report the notes should be loaded back with specific date and filters the the notes were first entered.  

So there can be a command button to actually save the notes where the filters/date are saved back to the db/table.   Can this be done with java script.. Can java be embeded in Power BI, or a VB script.  LEt me know if you need any other details.
0
I am a tinker and have search the web and gotten part of what I am doing to work. However, I need some advice on how to get a value from a database.
I need to get employee phone number from a database, VB, ASPNET, OLEDB.
The database has employee ID, full name, and phone.
I can connect to the database, but I need the query to return data, and the code to get the phone number. The query should return only one record because employee id is a unique value. Place the phone number in a session variable, session(“phone”).
Thanks for your help.
WCGee
0
I have a problem brewing at work. A new hire is formally educated in Excel and I am not. She asked me for help with a macro that wasn't working for her and she came to me as I am considered to be one of two experts here. The problem is that my brain is virtually incapable of learning anything on my own from manuals, I can only learn directly from other people. I've accumulated virtually all of my knowledge by asking questions here and “dumbing it down” to personally intuitive and very effective code. I guess I'm amazed at what I can do without formal training but more than ever now I need to understand how the formal syntaxes actually work.

The project is to find and copy Excel files in a designated folder and paste them into other customer specific folders, sub-folders of another designated folder. I created code for her on Monday which completely solved her problem using my kind of home-made super simple code, but she managed to fix her formal code over Christmas. The crux of my problem is that I have no idea of how her code can do what my code can do. The first code below is her revised code. The second is mine.

My first question is what exactly is an object such that FSO is one in  “Dim FSO As Object.” (Why isn’t it just defined as “Workbook?”) And how does that empower it to serve the objective described in my question above?

Second question: since she doesn’t define the variable names of the source files to be copied, how does her code identify the file to be …
0
We have been using the following lines of code in many places in our Access application and starting today its giving an error.
         Dim FSO As Object
         Set FSO = CreateObject("Scripting.FileSystemObject")

The error is 429 ActiveX cannot create object.
This is on Server 2008 and we are not experiencing this issue on another Server 2008 running this program and both show having the same identical Windows updates.
I have tried removing the last updates for the computer, but this did not resolve the issue. Regedit Scripting.FileSystemObject  permissions appears to be the same on both servers.
What else can I try to resolve this issue?
0
Hello,

I am getting an error while executing Stored procedure having both input and output parameters through VB Script and QTP.

Can you please check below stored procedure and the script I am trying and let me know what's wrong in thi

Stored Procedure:

create or replace procedure sproc_oraint02_send_email_test                                                                                                                  
      (                                                                                                                                                   
      ip_event         IN  EMAIL_DETAIL.EMAIL_EVENT%TYPE,                                                                                                 
      ip_sub_event     IN  EMAIL_dETAIL.EMAIL_SUB_EVENT%TYPE,                                                                                             
      ---- ip_file_dir      IN  VARCHAR2,                                                                                                                      
     ---- ip_file_name     IN  VARCHAR2,                                                                                                                      
      op_error         OUT VARCHAR2                                                                                                                       
      )                                                                                                      

Open in new window

1
Hello,

I have a vb6 solution that I am running with CRXIR2.  It is working well as I am passing the parameters to the report and letting it run.

I am only responsible for the form that runs the reports.

The team is now in the process of re-writing the program to VB.net.

Can I please get some advice on what I need to do to prepare for this.  I am taking a class in VB.net,   but I think that I am currently running the reports in a not very efficient way and I am willing to look at a different approach.  

I need advice on 2 things...
1.  Do I need to get a more current version of crystal?
2.  What is the most used way of running the reports, ie doing an SQL query in vb.net and passing that recordset to crystal or passing the parameters and letting crystal run the report.  

Based on the answers above, which way would be the easiest to  modify a report and test it?
Right now I just run the report in crystal and copy the rpt to directory and VB runs it.

My coding skills are only what I needed to do what I am doing now, so I'd like to keep it as simple as possible.

Thank you for your opinion and advice.
0
Hi Guys,

I have a simple VB script which sends a confirmation e-mail, and is working well.

I would like the script to count the number of files in a specific folder (incl. sub-folders) on disk, then include this number in the message text.


Example of the script below:

on error resume next

Const schema   = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 1
Const cdoSendUsingPort = 2
Dim oMsg, oConf

' E-mail properties
Set oMsg      = CreateObject("CDO.Message")
oMsg.From     = "sender@domain.com"  
oMsg.To       = "recipient@domain.com"    
oMsg.Subject  = "Subject Text"

oMsg.TextBody = "Body Text"

Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver")       = "192.168.21.22" 'server address
oConf.Fields(schema & "smtpserverport")   = 25              'port number
oConf.Fields(schema & "sendusing")        = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic         'authentication type
oConf.Fields(schema & "smtpusessl")       = "False"             'use SSL encryption
oConf.Fields(schema & "sendusername")     = "sender@domain.com" 'sender username
oConf.Fields(schema & "sendpassword")     = "Password"      'sender password
oConf.Fields.Update()

' send message
oMsg.Send()

' Return status message
If Err Then
    resultMessage = "ERROR " & Err.Number & ": " & Err.Description
    Err.Clear()
Else
    resultMessage = "Message sent ok"
End If

'Wscript.echo(resultMessage)
0
What's application server is not recommend virtualize and should be install on physical server?
0
Need a script that  will do  what is listed in the attached document  Set IE as default.  pc user will not have admin rights
V2-Link-Not-Opening-to-Web-Browser-.docx
0
Greeting Experts,

I need help updating the following script below with a function to ask for the user's credentials before starting the script. The purpose of the script is to copy files from a UNC path and copy them to a list of pc's in a text file, then execute the command to install the software. Can somebody help me with this script? .


$computers = Get-Content -“Path C:\Computers.txt"
foreach ($pc in $computers) {
    {
        Copy-Item "\\domain.com\ens_software\deployment\Folder\program.exe" -Destination "\\$pc\c$\Folder" -Force -Recurse
        Invoke-Command -ComputerName $pc -ScriptBlock {"C:\Folder\program.exe /install /quiet /norestart "}
    }
    Remove-Item -Path "\\$pc\c$\Folder"

Open in new window

0
I am using asp classic and freeASPupload to up load my files, i am also using highslide to resize on display,

i need to resize on upload, i have read there is a way to use highslide in conjunction with freeASPupload to do this but cant get it to work..

any help will be appreciated ty
0
Hello,

Please I have the Following macro excel :

ActiveSheet.Range("$K$4:$KP$4").AutoFilter Field:=", Criteria3:="Coller"

it has working in excel 2010 but it has stop working when I migrated to Excel in Office 365.

Please do you have any idea ?
0
I am trying to run .vbs script who reads data from Excel. It works fine when I run it from command line but it does not work if I run it from Task Scheduler, but if I run it as Administrators  from Task scheduler it works. But the I can only save the task as "Run only when user is logged on"

file
0
Hi, I've been dealing with over 8000 video files every month. And I need to quick write a program to pass a ffmpeg command to cmd.exe

Txtcommand ="timeout 5"
For i=0 to 8000
Txtcommand = Txtcommand & "&& ffmpeg -i " & Filelist.List(i) & " -vf ''"drawtext=fontfile=arial.ttf: text='wartermark'"" -f mp4 " & """" & "output" & i &".mp4"""
Next
Shell "C:\Windows\system32\cmd.exe /k " & Txtcommand & "&&EXIT", vbMinimizedNoFocus

Open in new window

It works perfectly If my file list contains less than 20~30 files (depends on path & file name length). More than 30 files, cmd won't launch, because of the maximum length of one command is limited by 8191 characters.

Tried to put shell in For...next loop and 8000 cmd windows open at the same time.

For i = 0 to 8000
Shell "C:\Windows\system32\cmd.exe /k ffmpeg -i " & Filelist.List(i) & " -vf ''"drawtext=fontfile=arial.ttf: text='wartermark'"" -f mp4 " & """" & "output" & i &".mp4"" &&EXIT", vbMinimizedNoFocus
Next

Open in new window


I need a solution to separate Txtcommand to multiple run, each run 8k characters.  
And how to make VB to know when the current shell command is done and run the next command.
Thanks you!
0
Hi All,

Hope your well,

I have a VB script which is nearly there but just a small part missing.

The script is being configured to delete certain contacts with a particular attribute set. Within that subset of contacts with this particular attribute im also adding some additional logic to not delete all of them e.g.

as an example: I look for contacts with extensionattribute1 set with "SPECIALATTRIBUTE", I then say, if email address 2 is populated DO NOT DELETE, move on to the next. My aim is to delete all of these contacts without an email address 2 set. The bit where im stuck is that I'm also trying not to delete contacts that have a certain domain e.g outlook.com but im not sure on the contains context. My ultimate goal is to look for contacts with a particular attribute, keep the ones that have an Email2address set and if their email1address contains outlook.com and then delkete the rest that do not match these conditions.


Set objRecord = objItem.Find("[Extensionattribute1] = ""SPECIALATTRIBUTE""")

While Not objRecord Is Nothing
      
      If objRecord.Email2Address = "" And objRecord.Email1Address <> "*OUTLOOK.com" Then objRecord.Delete

      Set objRecord = objItem.FindNext

Many Thanks.
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.