Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

VB Script

36K

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'm not sure if this is even possible but here it goes.

We use a cloud-based application that works only in IE (due to an ActiveX plugin).

Is it possible to open certain URL's in Outlook emails using IE?  Other URLs in emails can use the user's default browser of choice.  We just want hyperlinks going to one domain to use IE.

I'm not concerned about links outside of Outlook.  Those can use the default browser.  I'm concerned only with links in emails going to one domain.

I'm hoping this can be done with vbscript or a plugin of some sort.
0
Free Tool: SSL Checker
LVL 10
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

I am trying to get the function of Application.SumIf() and Application.CountIf() for an internal VBA array defined as Variant.

It is fairly easy to achieve if the criteria Crit in the (non-working) Application.CountIf(tmpArr, Crit) is just supposed to be Equal to the values in the array, but I need Crit to be able to contain criterias like >10, <5 and ideally even wildcards.

Below is a code snippet showing what I have tried for CountIf() , the error it produces and also how I hoped it would work.

Sub CountIfTest()
Dim tmpArr As Variant, Crit As String, tmp As Variant, i As Long
    Crit = InputBox("Criteria", , "<6")
    tmpArr = Array(5, 3, 12, 4, 0, 4, 3, 2, 1)
        
'    MsgBox Application.CountIf(tmpArr, Crit) 'Gives error "Object required" since tmpArr is not a Worksheet.Range()
    For Each tmp In tmpArr
        If tmp Like Crit Then i = i + 1         '"Like" doesn't work, but "If tmp = Crit" works
    Next tmp
    MsgBox "Like test " & i
    MsgBox "Filter test " & UBound(Filter(tmpArr, Crit, True, 0)) + 1                   'Works for Equal, but not for < or > or wildcards
    MsgBox "Match test " & Application.Count(Application.Match(tmpArr, Array(Crit), 0)) 'Works for Equal, but not for < or > or wildcards
End Sub

Open in new window


Any creative ideas?

Thanks,
Jörgen
1
I've built a pivot table that is being sent to multiple users via email. When the users receive the attachment, they should be able to press an update button I've created to update the pivot table.

When users hit the update button, they receive an error message stating "pivot table was saved without underlying data" .  I've selected Save Source Data with file AND Refresh Data When Opening The File in pivot table options. However neither option saves once the file is closed.

What can I add to the macro to override this issue?
0
Hi experts, How to set in sql command the table below where I wish to display by group the field name theId. Please see the table below!

Amount       Desc                                      TheId
10                 fair                                          x
12                 meals                                     y
15                 allowance                              y
15                 fuel                                         x
50                 Medicines                              x

I tried this command but it doesn't work;

Set rs = cn.Execute("Select Desc, theId, Amount from PList group by TheId")
0
HI Expert
usually i issue these commands manually
i want script to issue in order to cover this task
can you write a simple script for me to cover this two steps

1- change the path of your working directory!!!!!
 cd c:\program files (x86)\Citrix\Licensing\LS

2- execute this command in order to delete all occupied licenses.
for /f "tokens=1,2" %i in ('udadmin -list ^| find /i "_ud"') do @udadmin -f %j -user %i -delete

3- exit and finish

thank you in advance
0
Hi

I have 600 user accounts (within  OU14, OU15 ,OU16, OU17) that i have extracted in a notepad. I need to delete all these user accounts from our active directory which are not required any more. Is there any script or batch file or command that i can use to delete all these user accounts.
If so please post me the syntax to safetly delete them from the AD.

My Ad structure is like this :
Domain.local
       -Students
              -OU14
              -OU15
              -OU16
              -OU17

Thanks and any help would be great.
0
Hi,

I need a batch file script to execute from a citrix.  We need to publish 10 Websites in single page. User will select and click the website they want to use.  We used for Menu.hta and loading sites file into Menu. We are using Excel now for this but not looks good. can anyone provide script with other ideas to help me on this?
0
Hi

I am looking for  a VB script that would search full name or user name in the Excel spreadsheet.
It would be great if I could type user name or full name in the search box and scan against Excel Spreadsheet
The output should be exported to csv file and display on the page.

Can you please help me?

Thx, M
Test-groupname.xlsx
0
I want to process multiple files from the folder.

This is code.
$file = 'C:\temp\RP\test'
$xlApp = New-Object -Com Excel.Application
$xlApp.Visible = $false
$wb = $xlApp.Workbooks.Open($file + '.xlsx')
$filedest='C:\Temp\'
foreach ($ws in $wb.Worksheets)
{
  $ws.SaveAs($filedest + '_' + $ws.Name, [Microsoft.Office.Interop.Excel.xlFileFormat]::xlExcel12)
  break
}
$wb.Close(0)
$xlApp.Quit()

I tried using below  but  failed.
$file = Get-ChildItem "C:\temp\RP\" -Filter *.xlsx .

Could any one please hemp in this ?
0
HI,

A client has sent us an excel spreadsheet that references "sheet 3" in some formulas but the sheet is not listed along the bottom with the other sheets and if you right click any of the other 9 sheets the unhide option is greyed out.

Is there any other way to get access to this hidden sheet?
Thanks
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,
Extract all word files properties script.
I have few 1000's of files and want to extract all details possible to an excel, so i can compare and take some actions.
Like Owner name/system name etc etc
Can anyone help me please
0
I had this question after viewing Auto Close a Microsoft Word document with a VB MACRO.

It was very informative and was a macro for exactly what I wanted.

Unfortunately, when using that code and creating that macro then when I double click on the file then it would only open word and not the file.  
Once word was open then if I were to double ckick on the file, or opened the file from within word, then it would open and work fine.

I do not know if there is any way around this or what is specifically causing this in the macro itself that it does not open the document unless word is already running.

If you have any advice I would be most grateful!

Thank you,


Here is the original Macro instructions:

-Open the document you want to do this to
-From Word, press Alt-F11 to open the VBA/Macros editor (VBE) window
-Press control-r in the VBE to open/focus the Project window
-Look for the Project for the file you want this to happen on (should look like "Project (YourDocumentName)"
-Expand that project if not already expanded
-Expand the "Microsoft Word Objects" folder if not already expanded
-Double click on the "ThisDocument" object in that folder.
-In the code pane that opens up from there, paste in the following:

Private Sub Document_Open()
 StartCheckingIdle
End Sub

-Now, right-click on the ThisDocument object in the …
0
Hello,

I'm trying to find or create a VBScript that can query an AD "domain-local" group and export the members of the group to a text file.
The export of the members needs to be in the format of:  "DOMAIN\SAMAccountName"

DOMAIN is preferred to be in the NetBIOS format, but FQDN is also acceptable.

I need the domain to be prefaced because there are members of trusted domains in these groups which I must differentiate.

Thanks.
0
I am calling an oracle stored procedure that returns an out number parameter from vb.net but i get an error that its not returning anything when i test the procedure in pl/sql it works just fine  

this is the procedure
PROCEDURE Get_CUSTOMER_ID(opnCustomerId OUT number,
                           ipnServiceId IN number)
IS
cCustomerId number;
BEGIN 
  
   select s.customer_id INTO cCustomerId 
   from service s 
   where s.service_id = ipnServiceId;
   
   opnCustomerId := cCustomerId;
   
 END;

this is the procedure declaration 

[code]PROCEDURE GET_CUSTOMER_ID(opnCustomerId OUT number,
                          ipnServiceId IN number);

Open in new window


and this is the vb.net code calling the stored procedure

Dim oraCmd As New OracleCommand
            Try

                oraCmd.CommandType = CommandType.StoredProcedure
                oraCmd.Connection = oraConn
                oraCmd.CommandText = sSchema & ".CSM.GET_CUSTOMER_ID"2
                oraCmd.Parameters.Add("ipnServiceId", OracleDbType.Int32, ParameterDirection.Input)
                Dim paramCustomerId As OracleParameter = oraCmd.Parameters.Add("opnCustomerId", OracleDbType.Int32, ParameterDirection.Output)

                oraCmd.Parameters("ipnServiceId").Value = 3718968
                'oraCmd.Parameters("opnCustomerId").DbType = DbType.Int32
                'oraCmd.Parameters("opnCustomerId").Direction = ParameterDirection.ReturnValue
                oraCmd.Connection.Open()
                oraCmd.ExecuteScalar()
                Dim stringAccount As String = (paramCustomerId.Value).Value
                'accountId = Convert.ToDecimal(oraCmd.Parameters("opnCustomerId").Value.ToString)
                oraCmd.Connection.Close()
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK)
                oraCmd.Connection.Close()
            
            End Try

Open in new window

your help would be greatly appreciatedw
0
I have VB .NET code that is inserting jpg images into a Word document using the InLineShapes.AddPicture.  My problem is that my image quality gets degraded when doing this.  I have checked the "Do not compress images in file" under Word Advanced Options for "All New Documents".  With this checked, I can manually insert the jpgs and the image quality stays high, but this setting seems to be ignored when inserting using the AddPicture.  Is there a way to fix this issue?

Thanks
0
I have many Excel workbooks where users are allowed to only edit specific ranges. In order to audit the setup, is there a way to list all users that have permission to access ranges. I know I can do this manually, but I am looking for a way to do this through VBA.
I can loop through the workbooks and worksheets. Once I am on a particular sheet, how do I access the permissions?
0
Dears,

I have a XML file with content as below.

<?xml version="1.0" encoding="utf-8"?>
<!--Informations Vendor="XXX S.A."-->
<City>
      <Region>
            <Name>001</Name>
            <Name>002</Name>
            <Name>004</Name>
            <Name>005</Name>
      </Region>
</City>

Now, I need a VB script, which adds a <name> node with value '003' in an ascending order.

And the final content of the XML must look as below.

<?xml version="1.0" encoding="utf-8"?>
<!--Informations Vendor="XXX S.A."-->
<City>
      <Region>
            <Name>001</Name>
            <Name>002</Name>
                <Name>003</Name>
            <Name>004</Name>
            <Name>005</Name>
      </Region>
</City>

Please guide me how to write a VB script code for this.
I am struggling to do it for the time being. Your help is highly appreciated.
0
Hi,

i tried the below script to download all the attachment of incoming mails to my outlook automatically using "run a script" option. I wrote the script in vb editor for outlook and added a rule as well. But it is not downloading any attachments to the folder I specified in my script. Please help me analyze the issue.


script

Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "<path-to-save-the-files>"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub

Thanks
Bharath
0
Hi All,
I try to use this script to add uses to Outlook contact list and I'm getting this error
Line:46
Char: 21
Error: The server threw an exception
Code:80010105
Source:null


This is the script

'On the next line edit the file name and path as needed
Const WKB_PATH = "d:\test\StaffEmailn.csv"
Const SCRIPT_NAME = "Import Contacts"
Const olFolderContacts = 10
Const olContactItem = 2
Const olDistributionListItem = 7


Dim excApp, excWkb, excWks, olkApp, olkSes, olkFld, olkCon, olkLst, olkRcp, lngRow, arrMbr, varMbr

'Connect to Outlook
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
olkSes.Logon olkApp.DefaultProfileName

'Get the target folder
Set olkFld = olkSes.GetDefaultFolder(olFolderContacts)

'Connect to Excel
Set excApp = CreateObject("Excel.Application")
Set excWkb = excApp.Workbooks.Open(WKB_PATH)

'Main routine
For Each excWks In excWkb.Sheets
    lngRow = 2
    For lngRow = 2 to excWks.UsedRange.Rows.Count
        If excWks.Cells(lngRow, "A") = "" then
            'Create a distribution list
            Set olkLst = olkApp.CreateItem(olDistributionListItem)
            olkLst.Subject = excWks.cells(lngRow, "H")
            arrMbr = Split(excWks.Cells(lngRow, "I"), ";")
            For Each varMbr in arrMbr
                Set olkRcp = olkSes.CreateRecipient(varMbr)
                olkRcp.Resolve
                olkLst.AddMember olkRcp
            Next
            …
0
Free Tool: ZipGrep
LVL 10
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

I know similar questions have been asked, however, I feel I need a little more explanation.
We have a website which was developed in VB.NET. I now have to add additional features to this site. The site has a master page as well. In addition we have am objects folder which has a lot of *.vb objects.
I'd really prefer to develop these features using C# as eventually the app will become a single code base and migrated to MVC for multitenancy. Am I able to do this and still use the VB objects and template master page? I think so since they both use the same IL. If so, how would I go about doing this?
1
Hi,

I`ve got a project folder at work. We`ve got severals documents into it and each time, we`ve got to write in the relevant case the same information regarding the project, like name, project number...

Is there a way to automatically fill those cases?

Best Regards,
0
I have a small windows form with login buttons to a website.

Now, I would like to add a 'Text Box' or something that will give me the output received as 'Success' & 'Failed'.

Like, if the web page text / header after the login is something like 'Login success' so it will type OK + Username to the textbox, if it's 'Failed' so it will type BAD + Username..

I just need an example to understand how I should start with this, Thank you!

This is part of my code:

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

WebBrowser1.Document.GetElementById("username").InnerText = user.Text$

WebBrowser1.Document.GetElementById("password").InnerText = pass.Text$

WebBrowser1.Document.GetElementById("login_button").InvokeMember("Click")

I added this code:

logbox.AppendText(user.Text & Environment.NewLine)

now It will just add the last username used to my textbox..

I need to make it wait for the page response and translate it to failed or good.

This is what I tried:

        Dim result
        If WebBrowser1.Document.Body.InnerHtml.Contains("Login Failed") Then
            result = "Bad"
        Else
            result = "Good"
        End If

and then:

logbox.AppendText(user.Text + result & Environment.NewLine)

But I don't know if it's actually waiting for the page to fully reload?
0
Hi,

I'm creating a windows form with WebBrowser using visual basic.
I'm doing a form filler for my website.
I have 5 text boxes to fill up: name, last name, email, user id, password
Meanwhile this is part of the code I have, everything entered manually and when I click the button it will insert the values to the correct boxes in the website.

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        WebBrowser1.Document.GetElementById("name").InnerText = name.Text$

        WebBrowser1.Document.GetElementById("lastname").InnerText = lastn.Text$

        WebBrowser1.Document.GetElementById("email).InnerText = email.Text$

        WebBrowser1.Document.GetElementById("userid").InnerText = id.Text$
       
        WebBrowser1.Document.GetElementById("password").InnerText = pw.Text$

        WebBrowser1.Document.GetElementById("button").InvokeMember("Click")

Now, it's working fine, when I enter value to each text box, it will enter the value to the correct text box in the web page.
I Need to automate it somehow, I also want the 'USERID' one to change the value between 5000-9000 every time, so it will use 5000 first time, then 5001, 5002 and so on.
0
I'm creating a windows form with webbrowser in VB.

I need to find a way to simulate a closing and reopen of the browser.

The thing I'm trying to do works when I just close & reopen the program, But when I'm trying to refresh the page with a button:
 WebBrowserReadyState.Complete - It doesn't help.
Also .Navigate to about:blank and going back to the original URL wont help, only re open would.
0
Hi,
I received a new computer last week but cannot get Task Scheduler to successfully run a VBS script.  It says it is running but the spreadsheets are not updating.  I created a new script to open Notepad and type a few words and Task Scheduler says it is running, ran successfully, but it did not..Notepad never opened.

I can manually run both scripts and they work fine.  Spreadsheets get updated and Notepad opens, types a few words, and stays open until I close Notepad.

My company's computer support has not been able to help at this time and I am currently waiting for the next level of help.  However, that could be more than a week until someone contacts me.

Attached are some screen shots I hope will help, with some identifying text blacked out with a description of what info was there.

Would any of you have any ideas as to why the scripts work when I double click on them manually to get them to run but Task Scheduler will not successfully get them to run, even though it says they are running?

Thanks.
0

VB Script

36K

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.