VB Script

36K

Solutions

25

Articles & Videos

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

Hi Experts. I was able to source this VBA code from a question answered but I need to modify it slightly. I have X number of workbooks with Y number of worksheets in each book. I have information that I would like to compile onto a single master data workbook. The code below is able to gather the data from the first sheet from all the selected workbooks. I need it to do the same for the remaining worksheets. Please help me with this request! Would really appreciate the help. :)

Sub MergeTest()

    Dim SummarySheet As Worksheet
    Dim FolderPath As String
    Dim SelectedFiles() As Variant
    Dim NRow As Long
    Dim FileName As String
    Dim NFile As Long
    Dim WorkBk As Workbook
    Dim SourceRange As Range
    Dim DestRange As Range
    Dim LastRow As Long

    ' Create a new workbook and set a variable to the first sheet.
    Set SummarySheet = Workbooks.Add(xlWBATWorksheet).Worksheets(1)

    ' Open the file dialog box and filter on Excel files, allowing multiple files
    ' to be selected.
    SelectedFiles = Application.GetOpenFilename(filefilter:="Excel Files (*.xl*), *.xl*", MultiSelect:=True)

    ' NRow keeps track of where to insert new rows in the destination workbook.
    NRow = 1

    ' Loop through the list of returned file names
    For NFile = LBound(SelectedFiles) To UBound(SelectedFiles)
        ' Set FileName to be the current workbook file name to open.
        FileName = SelectedFiles(NFile)

        ' Open the …
0
Industry Leaders: We Want Your Opinion!
Industry Leaders: 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!

I have the following line...

Set objFolder = objShellApp.Namespace("C:\Users\pf1004\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu")

Which only applies to the location within the user PF1004's user profile, but I want to use it in a logon script.  How do I change this to an environment variable, i.e. how do I change the path to something like...

%APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu

I'm unsure about using variables in VB because I've seen people use %varable% and others use $env:variable, and even then I don't kow how to include that in the above path.

Thanks.
0
Hello,

Can Excel VBA code designate a specific string of text from within a cell in the same way the =MID() function can extract a string of text?

For example, suppose cell B4 contains the following entry:

        The quick brown fox jumped over the lazy dog.1

And suppose that cells D4 & E4 contain the values 11 & 5 respectively. Then the formula =MID(A2,D4,E4) entered in cell G4 would return the string "brown" as shown here:

2017-06-23e_EE.PNG
2017-06-23d_EE.PNG
How could the same three cell values be captured by VBA and assigned to variables to be used further down in the code?

Thanks
0
Need assistance with a powershell/vbs script to do the following:

We need to monitor the following path \\SERVER\folder.  When a new folder is created that's an indication of a failure of a background process. Once the new folder is detected we need to send an email alert. We are looking to received the alert only when newly created folders (now-15 minutes or so)or just the last date (compare with the most recent folder date creation) if newer then sent alert.

We do have SCOM and so we might run the script from there otherwise from the server itself (windows server)

Can you someone please assist
0
I have this Summary tab and different supplier tabs that are linked from an access table that I need information pulled from to populate the Summary sheet.  Wanted to see if this is possible to accomplish by entering a number instead of manually entering this information.

Basically if you enter the RFQ number in cell B3 then it would pull it's corresponding row information and populate the specific cells in the summary sheet tab.  See example in the attachment.
C--Users-Luis.Freund.EXT-Desktop-Lu.xlsm
0
Hi Experts,

I am trying to update legacy ASP code amd I am starting out with
<%@ Language=VBScript %>

<%
Session("isLocal") = True

Session("getRates") = ""
Session("getRatesTime") = DateAdd("n", -1, Now())	'DateAdd Intervals: s=secs; n=minutes; h=hrs

Session("Root") = "../"
Session("sourceID") = 1

If (Session("isLocal") = True) Then   
    %>

    <!--  <!-- #include file = "../../CSSN_subdomains/includes/common.asp" -->
    <!--  <!-- #include file = "../../CSSN_subdomains/includes/functions.asp" -->
    <!--  <!-- #include file = "../../CSSN_subdomains/includes/PageSetup.asp" -->

    <%
Else
    %>

    <!--  <!-- #include virtual = "/includes/common.asp" -->
    <!--  <!-- #include virtual = "/includes/functions.asp" -->
    <!--  <!-- #include virtual = "/includes/PageSetup.asp" -->

    <%
End If

Open in new window


However, I am getting the following error despite that Session("isLocal") is True, so lines 23-25 should never be executed.
Active Server Pages error 'ASP 0126'

Include file not found

/CSST_subdomains/cart.citysightseeingtoronto.com/index.asp, line 23

The include file '/includes/common.asp' was not found.

Open in new window


What is going on?

Any help will be greatly appreciated.
0
Since we upgraded to SQL 2008 from SQL 2000 i have faced the following problem: I can run the VB Script that runs a DTS from the SQL Server, however running the same VB Script to to execute the DTS from a client PC has the above error message. I have tried, installing MS SQL studio on the client connecting to the DB instance and tried running the VB Script but it still wont work. im lost, please help

Regards,
Grand
0
hi all
i want a line per ittem, please help

ObjSendMail.HTMLBody = "Nombre:" +" " + Request.Form("fname") & Chr(10) & "Email:" +" " + Request.Form("email") & Chr(10) & "Consultorio:" +" " + Request.Form("consultorio") & Chr(10) & "Comentarios:" +" " + Request.Form("message")

Open in new window


tsm
0
So, I have to look through a worksheet and identify where groups of numbers match.

Could someone help me with code which will do this for me please ?

Also, would it be possible to identify each matching group of number with their own colour ?

I have attached a worksheet to illustrate


thanks
006-triplet-duplicate-id-EE.xls
0
I have code that looks for dups  and removes the second row.

Getting the error on "xlUp"

  Dim i As Long, lastRow As Long

lastRow = Range("A" & Cells.Rows.Count).End(xlUp).Row

For i = lastRow To 1 Step -1
    If Application.CountIf(Range("A1:A" & lastRow), Range("A" & i)) > 1 Then _
        Rows(i).EntireRow.Delete
Next i

Open in new window

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 wish to add 1 day on the edate I have coded below. Something like this (edate + 1). can i do this? Thanks!


Set rs = cn.Execute("Select Proname, REMARK, TheDate, INPro, OUTPro, BALANCE from Stock where PROCODE='" & code & "' And TheDate Between '" & sdate & "' And '" & edate & "' Order by icount")
0
Previous I raise this question to select and display the multiple chart in one sheet and mr.mlmcc he gave me the solution its worked fine but the selection combo box is Activex control. i opened the file in my company pc activex control not working so i tried to change with Form control combo box and i add the code its getting the object error. please kindly modify the code to form control combo box to display the chart.
Private Sub ComboBox1_Change()

If ComboBox1.Text = "alpha chart" Then
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveSheet.Shapes("Chart 1").ZOrder msoBringToFront
ElseIf ComboBox1.Text = "Bravo chart" Then
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveSheet.Shapes("Chart 2").ZOrder msoBringToFront
Else
    ActiveSheet.ChartObjects("Chart 3").Activate
    ActiveSheet.Shapes("Chart 3").ZOrder msoBringToFront
End If

End Sub

Open in new window

View-chart-by-selecting.xlsm
0
Hi there,

I am trying to work on an Excel Macro that can generate a html/ htm page that lists the name of every tab name for every excel file in a folder.

For each listed tab name and file name when clicked on, it will hyper link directly to the file/ to the tab.

For example in the generate html page:

Excel File Name 1
 - Tab 1
 - Tab 2
 - Tab 3

Excel File Name 2
 - Tab A
 - Tab B
 - Tab C

Any advice on how do i write the vb code in the excel macro to generate such a page. Thanks!
0
I have rows of data, from which I need to sort into every possible combination of three (as per worksheet)

I think there are 18 or 20 possible combinations altogether, I have done half a dozen for illustration.

Could someone help me with code that will sort thousands of rows into this format please ?


thanks

006-triplet-studies-EE-sample.xls
0
Hello,

Can someone explain or point me to a good explanation re how to know where to insert VBA code in the Visual Basic Editor in Excel 2010?

I know very little VBA and my experience is pretty much limited to copying/pasting code provided by EE experts over the years. However, once in the Editor, I'm always a bit puzzled about knowing where to insert it.

The tree to the left in the Editor lists each sheet tab and "ThisWorkbook" which I assume enables you to apply code so it applies only to an individual tab but not others. However, there are also Modules displayed in the tree which, at times, I have seen containing code. Also, the actual code area has two drop-down menus which I sometimes see display different headings. And finally this evening, I came across something saying to "[press] Ctrl+G to open the immediate window".

By the way, I upgraded to Excel 2013 for a while but then opted to go back to Excel 2010 with its option to to open multiple instances or multiple workbooks in a single instance so they can share a common Ribbon, Quick Access Toolbar & Formula Bar, etc.

Thanks
0
I am working with a number of large .csv files in Windows 7,  where I need to count the number of records and if possible iterate through the files and output the filename and record count of all the .csv files (in VBSCript or Windows Batch).    Any help is greatly appreciated. Thanks.
0
As one expert give me a solution of my question now I want that by click button in MASTER Sheet data of boys and girls separately send to a  new attendance workbook by the apply condition of group and gender.
student-record-workbook_v4.xlsm
ET-Attendance---Marks-sheets-Boys--.xlsx
0
How can I get the User's public IP ?
I am using asp.net / vb
0
Hi,

We have a login page that saves a cookie so that the username is stored and shows next time the user logs in.
We ran a security scan and got the following alert:

"Cookie without 'httpOnly" flag

Below is the code for setting up the cookie. How can we resolve the issue of the alert?

        function createCookie(name, value, days) {
            if (days) {
                var date = new Date();
                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                var expires = "; expires=" + date.toGMTString();
            }
            else var expires = "";
            document.cookie = name + "=" + value + expires + "; path=/";
        }

        function eraseCookie(name) {
            createCookie(name, "", -1);
        }

Open in new window

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

The title pretty much says it all.  I created my array as follows:


' Multidimensional Array
	' arrTransactions(col,row)
	ReDim arrTransactions(6,0) 

	
	' SQL Statement
	strSQLStatement = 	"SELECT transactionNumber, jobNumber, eventName, collateralID, arrivalDate, returnDate, quantity " & _  
						"FROM collateralOut " & _
						"WHERE collateralID  ='" & strCollateralID & "' " & _
						"ORDER BY arrivalDate DESC" 

	' Connection
	Set conn = Server.CreateObject("ADODB.Connection")
	conn.open connectionStr

	' Create our recordset
	set strFilename=Server.CreateObject("ADODB.recordset")
	strFilename.Open strSQLStatement, conn

	If Not strFilename.EOF Then
		strFilename.MoveFirst
		
		noRecord = "False"
		
		i = 0

		While Not strFilename.EOF

			arrTransactions(0,i) = strFilename.Fields("transactionNumber").Value
			arrTransactions(1,i) = strFilename.Fields("jobNumber").Value
			arrTransactions(2,i) = strFilename.Fields("eventName").Value
			arrTransactions(3,i) = strFilename.Fields("collateralID").Value
			arrTransactions(4,i) = strFilename.Fields("arrivalDate").Value
			arrTransactions(5,i) = strFilename.Fields("returnDate").Value
			arrTransactions(6,i) = strFilename.Fields("quantity").Value

			' Counter
			i = i + 1
			
			' Preserve array position
			ReDim Preserve arrTransactions(6,i)

			' Move to the next record
			strFilename.MoveNext
		Wend
		
	Else
		noRecord = "True"
	End If
	
	' Close our connection
	strFilename.Close
	Set strFilename = Nothing

Open in new window



Then I wrote the following to loop through the array but it's not working:
                 <table border="1" cellpadding="5" cellspacing="1" width="80%">
                 	<tr>
                    	<td bgcolor="#eeeff0"><strong>Trans#</strong></td>
                        <td bgcolor="#eeeff0"><strong>Event Name</strong></td>
                        <td bgcolor="#eeeff0"><strong>Event Start</strong></td>
                        <td bgcolor="#eeeff0"><strong>Qty Ordered</strong></td>
                    <tr>
                 	<%
						If NoRecord = "False" Then
							For i=0 to (UBOUND(arrTransactions) - 1)
					%>
					<tr>
                    	<td valign="top"><%= arrTransactions(0,i) %></td>
                  		<td><%= HTMLDecode(arrTransactions(2,i) ) %></td>
                        <td valign="top"><%= arrTransactions(4,i) %></td>
                        <td valign="top" align="center"><%= arrTransactions(6,i) %></td>	
                    </tr>
					<%
							Next
						Else
					%>
					<tr>
                    	<td colspan="5"><strong>No Records Found</strong></td>
					</tr>
					<%
					End If 
					%>
                </table>

Open in new window


When I load the page it only loads 6 records and stops.  There are about 30 records the page should be displaying.  

I have a feeling that this line here is wrong...

For i=0 to (UBOUND(arrTransactions) - 1)

Open in new window


... but I'm not sure how to fix it.  Can someone please help me?
0
we are using shutdown -r -t -f 00 to restart the server . same command I need use to run against the multiple servers .

thanks in advance...
0
Hello:

I need to compose VB scripting for Microsoft Dynamics Integration Manager for GP 2015.

Specifically, I need to write a script that will pull all lines of detail into the Note field--not just one line of detail.

This is not the standard "CurrentField", "SourceField" scripting.  I need scripting that will directly update the SY03900 table in SQL.

Any help would be much appreciated!

Thanks!

John
0
I want a tool that will run through our website once daily and send a report of any broken links it finds. I can do it either in VB and use Access 2003 here at the office or I can install it as a php app on our  web server.

Any ideas?
0
I want to send sms from vb6 application. I have third party tool. He has given http://mobile.sendsms.com/api/smsapi.aspx?username=abcd&password=abcd&to=MOBILENO&from=fromhdr&message=this is test sms


following command i have written in vb6 code but it is not working.

TextString= "http://mobile.sendsms.com/api/smsapi.aspx?username=abcd&password=abcd&to=MOBILENO&from=fromhdr&message=this is test sms"
   
    Open "c:\SmsSend1.Bat" For Output As #1
    Print #1, TextString
    Close #1
    Shell "C:\SmsSend1.Bat", vbHide



in vb6 how to execute this command in vb6. I want to execute this command after saving data record.


Thanks
0
Write SQL or VB in MS Access to do the following:

1) Populate updated (new Sales Orders) QB order data (specific field names already identified) to existing table based on Greater than newest Timestamp of previous data load. Original SQL Query attached, cannot construct the Update Query to success.

2) Automate the Update Query to run incrementally every 5 minutes

3) Run Update Query when QB is closed.  Currently QB must be open.

All this is one way between MS Access database and QODBC.

I have attached a sample of the output data from QB as well as the Append script to populate the Master Table.  We cannot overwrite this data, only add to it. The processes within the MS Access program will do the data cleanup.
Master-Data-Query-from-QB.docx
Sample-Layout-of-Master-Data.xlsx
0

VB Script

36K

Solutions

25

Articles & Videos

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.