Quantcast
Channel: VBForums - ASP, VB Script
Viewing all 662 articles
Browse latest View live

autofill web forms using excel vba script

$
0
0
hi,

I am not familiar to VBA and i made this script by referring a video posted by some user.

What i am trying to do is to autofill web forms using cell values from excel.

This is just a sample...if i get this right ill try to do this on actual website.

i got the following error upon execution..Run-Time error '424' : object required.

Need your help!!

CODE:-

Sub automaticformfilling()
Dim ie As Object

Set ie = CreateObject("internetexplorer.application")

With ie
.Visible = True
.navigate "http://formsmarts.com/html-form-example"
'Wait for loading

Do While .busy
DoEvents
Loop

Do While .readystate <> 4
DoEvents
Loop


End With

[ie.document.getelementbyid("u_u9x_4607").Value = Sheets("sheet1").Range("A1").Value[/B] 'This is where i get the error...


End Sub

Is there a way to connect or link a vbscript to an excel file?

$
0
0
Hello Everyone,

 let me explain what I'm trying to get done, about once every 2 weeks I need to go into the warehouse write down every product's serial number we have and its location from there I must go into our system's inventory and manually enter the serial number and then change its location (our system is old by the way). My idea was to create vbscript that auto types and navigates through my system which I was able to do and save me some time but I still have to edit the script with the updated locations and it takes a while to edit that huge pile of text... (I'm still new to vbscripting) so I was wondering is there a way to link my vbscript to an excel file. for example, have it nice and organized like:

Item Number   Description           Location    update

FP38466     DB1D Gloss Black        BW111    yes or true

then have the vbscript check to see if a certain item needs to be updated and if it does it will update it and if not, it will just skip that item. Here is how my script mostly looks like:

WshShell.SendKeys "FP38466{ENTER}"
WScript.Sleep 200
WshShell.SendKeys "{ENTER}"
WScript.Sleep 300
WshShell.SendKeys "e"               (This is to go to the edit screen)
WScript.Sleep 200
WshShell.SendKeys "{ENTER}{ENTER}{ENTER}{ENTER} " (This is so I can get to the location)
WScript.Sleep 200
WshShell.SendKeys "BW111{ENTER}"
WScript.Sleep 300
WshShell.SendKeys "s"               (This is to save my changes)
WScript.Sleep 300

I have the navigation down but is there a way to instead of writing the location number in the script, it will go into the excel file look at that location cell and type that instead? also since I basically have this for every item is there a way to tell the script to look to see if this item need to be updated and if it doesn't to just skip it. I just don't know if you can link certain areas of the script with certain excel cells. If anyone knows a better method to do this I am open to suggestions.

I've been in other forms and I've been told it's not possible because Excel uses VBA so i was wondering as an alternative can the VBA get the information i need and open up notepad and then type everything i asked for in VBScript form? i know this sounds like a huge mess but it really doesn't help that the database program I'm using is from 1998 and i have to connect to a VN to even use it, the VN is also restricted from going online so i don't have many options sadly. The program i use is called SWIDS.

Thank you in advance.

combination of gicen values to sum upto range of target value

$
0
0
Hello,

need help to improve the VB code ( Excel macro ) to find out combination of values which will sum up to the given target range..

For instance, the given list of values are 1,3,2,4,2,2.9,2.5,1.5,3.8 target value 4.8 to 5.2..then the macro need to give the combinations of values whose sum will be 4.5 to 5.2..

Also please note that the combination may be 2 values / 3 values / 4 values/ 5values..

I have a code from internet which gives the combination for single target value and not for a range..

The code is below,

Sub startSearch()
'The selection should be a single contiguous range in a single column. _
The first cell indicates the number of solutions wanted. Specify zero for all. _
The 2nd cell is the target value. _
The rest of the cells are the values available for matching. _
The output is in the column adjacent to the one containing the input data.

If Not TypeOf Selection Is Range Then GoTo ErrXIT
If Selection.Areas.Count > 1 Or Selection.Columns.Count > 1 Then GoTo ErrXIT
If Selection.Rows.Count < 3 Then GoTo ErrXIT

Dim TargetVal, Rslt(), InArr(), StartTime As Date, MaxSoln As Integer, _
HaveRandomNegatives As Boolean
StartTime = Now()
MaxSoln = Selection.Cells(1).Value
TargetVal = Selection.Cells(2).Value
InArr = Application.WorksheetFunction.Transpose( _
Selection.Offset(2, 0).Resize(Selection.Rows.Count - 2).Value)
HaveRandomNegatives = checkRandomNegatives(InArr)
If Not HaveRandomNegatives Then
ElseIf MsgBox("At least 1 negative number is present between positive numbers" _
& vbNewLine _
& "It may take a lot longer to search for matches." & vbNewLine _
& "OK to continue else Cancel", vbOKCancel) = vbCancel Then
Exit Sub
End If
ReDim Rslt(0)
recursiveMatch MaxSoln, TargetVal, InArr, HaveRandomNegatives, _
LBound(InArr), 0, 0.00000001, _
Rslt, "", ", "
Rslt(UBound(Rslt)) = Format(Now, "hh:mm:ss")
ReDim Preserve Rslt(UBound(Rslt) + 1)
Rslt(UBound(Rslt)) = Format(StartTime, "hh:mm:ss")
Selection.Offset(0, 1).Resize(ArrLen(Rslt), 1).Value = _
Application.WorksheetFunction.Transpose(Rslt)
Exit Sub
ErrXIT:
MsgBox "Please select cells in a single column before using this macro" & vbNewLine _
& "The selection should be a single contiguous range in a single column." & vbNewLine _
& "The first cell indicates the number of solutions wanted. Specify zero for all." & vbNewLine _
& "The 2nd cell is the target value." & vbNewLine _
& "The rest of the cells are the values available for matching." & vbNewLine _
& "The output is in the column adjacent to the one containing the input data."
End Sub


Thanking You

Missing a MIME entry on downloading a TEXT file?

$
0
0
Help

This code worked fine on my clients 2003 server for simply downloading a TEXT file

Response.Clear()
Response.ContentType = "text/plain"
Response.AppendHeader("Content-Disposition", String.Format("attachment;filename={0}", %Trim(savename)))
Try
Response.TransmitFile(thePath)
Catch e1 System.Exception
Message = e1.ToString()
ltlAlert.text = "alert('" + Message + "')"
leavesr
EndTry
Response.End()

However -- they are going to a 2008 server and it no longer functions. What it downloads is the HTML of the page where the download button it. Please see attached.
What am I missing in the 2008 IIS configuration? A mime type??

thanks

gollnick
Attached Files

Update Access with VBscript

$
0
0
I have started a thread previously on updating a VPS server, but now I wish to explore updating a local server database through the internet.
This is the previous thread:
http://www.vbforums.com/showthread.p...VPS&highlight=

I have a VB6 program and a database on our local file server.
I now wish to change the program so that users on our construction sites can update the database via the internet by way of scripts.
I presume that I need a scripting file on the server which can update the database and that the VB6 program should be changed to send scripts to the database.

Can you please steer me into this unfamiliar ground.

Thanks
PK

[RESOLVED] Run exe from project sources

$
0
0
Hi,
I am trying to insert a exe to my VB project that should be started from my project resources (not from a directory on the pc) after a timer expires. Because I've never done it before and I still have no idea how I do it correctly I was trying to start the exe from my resources with Process.Start but of course it didn't worked. I also did all the things that are mentioned on other forums/threads but I don't get the code I need to run the exe from my resources. It would be a pleasure if someone could help me out or preferably write me a bit of code that I can just add to the project.

Much thanks :)

Attached Images
 

[RESOLVED] Missing a MIME entry on downloading a TEXT file?

$
0
0
Help

This code worked fine on my clients 2003 server for simply downloading a TEXT file

Response.Clear()
Response.ContentType = "text/plain"
Response.AppendHeader("Content-Disposition", String.Format("attachment;filename={0}", %Trim(savename)))
Try
Response.TransmitFile(thePath)
Catch e1 System.Exception
Message = e1.ToString()
ltlAlert.text = "alert('" + Message + "')"
leavesr
EndTry
Response.End()

However -- they are going to a 2008 server and it no longer functions. What it downloads is the HTML of the page where the download button it. Please see attached.
What am I missing in the 2008 IIS configuration? A mime type??

thanks

gollnick
Attached Files

AJax and Server 2008 R2 - Failure to load Assembly

$
0
0
New to Ajax. Developed web application on Wndows 7 Pro using VS 2010 and the 4.0 framework. Using Ajax and the tab controls. Works fantastic on the development system
Send it over to the Windows 2008 Server R2 and getting the attached error. Could not load assembly 'AjaxControlToolkit' .... (see rest of the attached error please)

Can anyone point to/give a resolution for this? Thanks

gollnick
Attached Images
 

Need help fixing vbs script

$
0
0
hi,

i need help fixing a vbs script if anyones good with it. When i run on on a few machines it says "invalid character" when it is tested. Thanks.

blog:

https://www.eventsentry.com/blog/201...ws-softwa.html

code:

‘ Lists all logical drives on the local computer which are configured for
‘ software RAID. Returns an %ERRORLEVEL% of 1 if any redundant drive is
‘ not in a “Healthy” state. Returns 0 otherwise.
‘
‘ Supports Windows Vista/7, Windows 2008/R2

Option Explicit

Dim WshShell, oExec
Dim RegexParse
Dim hasError : hasError = 0

Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set RegexParse = New RegExp

‘ Execute diskpart
Set oExec = WshShell.Exec(“%comspec% /c echo list volume | diskpart.exe”)

RegexParse.Pattern = “\s\s(Volume\s\d)\s+([A-Z])\s+(.*)\s\s(NTFS|FAT)\s+(Mirror|RAID-5)\s+(\d+)\s+(..)\s\s([A-Za-z]*\s?[A-Za-z]*)(\s\s)*.*”

While Not oExec.StdOut.AtEndOfStream
Dim regexMatches
Dim Volume, Drive, Description, Redundancy, RaidStatus
Dim CurrentLine : CurrentLine = oExec.StdOut.ReadLine

Set regexMatches = RegexParse.Execute(CurrentLine)
If (regexMatches.Count > 0) Then
Dim match
Set match = regexMatches(0)

If match.SubMatches.Count >= 8 Then
Volume = match.SubMatches(0)
Drive = match.SubMatches(1)
Description = Trim(match.SubMatches(2))
Redundancy = match.SubMatches(4)
RaidStatus = Trim(match.SubMatches(7))
End If

If RaidStatus <> “Healthy” Then
hasError = 1
WScript.StdOut.Write “**WARNING** “
End If

WScript.StdOut.WriteLine “Status of ” & Redundancy & ” ” & Drive & “: (” & Description & “) is “”” & RaidStatus & “”””
End If
Wend

If (hasError) Then
WScript.StdOut.WriteLine “”
WScript.StdOut.WriteLine “WARNING: One or more redundant drives are not in a “”Healthy”” state!”
End If

WScript.Quit(hasError)

Copying a very wide CSV file to Excel fails with error message

$
0
0
Hello,

A complete Newbie to VB Scripting. I have a table with over 260 columns which I am writing to a CSV file from SSIS. Due to excel limitations, I cannot write directly to a pre-formatted excel template with a header.

So I am looking at using a script task in SSIS which will copy the CSV without the header to the Excel file starting at a specific row (A4).

I am trying the below first from the command line, but it fails with an error message:

"The information cannot be posted because the copy area and paste area are not the same size. "

However, the CSV and the Excel template are identical.

What am I doing wrong here?

is there a better way to do write this script so that it can be invoked from SSIS?

Thanks in advance,
KB

Dim xlApp
Dim xlBook
Dim CSVBook

'Opens the Excel file in Excel
Set xlApp = CreateObject("Excel.Application")
xlApp.visible = true
Set xlBook = xlApp.Workbooks.open("C:\TEMPLATE.xls")

Set CSVBook = xlApp.Workbooks.open("C:\active.csv")

Dim xlToRight
Dim xlDown


xlToRight=-4161
xlDown=-4121

CSVBook.ActiveSheet.Range("A1").Select
CSVBook.Activesheet.Range(xlApp.Selection, xlApp.Selection.End(xlToRight)).Select
CSVBook.Activesheet.Range(xlApp.Selection, xlApp.Selection.End(xlDown)).Select
xlApp.Selection.Copy

xlBook.Activate
xlBook.Sheets("MTD").Select
xlBook.sheets("MTD").Range("A4").Select
xlBook.sheets("MTD").Paste

xlApp.quit
Set xlApp = Nothing
CSVBook.close

Read a source code from web page and extract some data from it

$
0
0
Hi :wave:
I want to read a source code from web page and extract some data from it. I used here in my example a RegEx for extracting the data, but i didn't get any data, perhaps this is due from unicode or the pattern dosn't match ? When i test this pattern with RegExBuddy it match, but in vbscript no ? Perhaps, i miss something in the code, or i must re-write by another way ?

Here is my try :
Code:

sSrcUrl = "https://fr.giveawayoftheday.com/"
Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
bGetAsAsync = False
oHTTP.open "GET", sSrcUrl, bGetAsAsync
oHTTP.send
If oHTTP.status <> 200 Then
WScript.Echo "unexpected status = " & oHTTP.status & vbCrLf & oHTTP.statusText
WScript.Quit
End If
Data = oHTTP.responseText
wscript.echo Extract(Data)
'****************************************************************
Function Extract(Data)
        Dim oRE,oMatches,Match,Line
        set oRE = New RegExp
        oRE.IgnoreCase = True
        oRE.Global = True
        oRE.MultiLine = True
        oRE.Pattern = "<div class=""giveaway_wrap cf"">(\r.*\n.*){17}</div>"
        set oMatches = oRE.Execute(Data)
        If not isEmpty(oMatches) then
                For Each Match in oMatches 
                        Line = Match.Value
                        Extract = Line
                Next
        End if
End Function
'*****************************************************************

[RESOLVED] Adding items from one page to another

$
0
0
I've stated previously that I'm new to this so this is something I don't know how to do so this is probably a rather simple request and hoping the solution is as equally simple. I have an add item button on one page and when I click a selected item from a listbox I want to send it to a different page in an empty listbox (Think of a user selecting an item on say Amazon for example and sending it to cart.)

Creating a folder based on today's date and copying from another folder

$
0
0
Hi

I have the following VB Scripts that work but I would like to edit it so it is just one VB Script instead of 2. The first one shows a pop up message to show the user don't use the screen as as it's running. At the moment at every login of the PC this is run (Shows a timed pop up message for 1 minute)

Dim counter
Dim oShell
counter = 60
Set oShell= CreateObject("Wscript.Shell")
While counter > 0

oShell.Popup " Left " & counter & " Seconds",1,"Please wait..."
counter = counter-1
CreateObject("WScript.Shell").Popup "Copying folder... Notepad will start automatically", 1, "Please wait..."
Wend

I have set it to 1 min as this I see this enough for the script to copy the folder. There is another vbscript running with the code (All this is doing is creating a folder based on today's date and copying contents from one folder to another folder as a backup. Now what I want really is to combine these 2 scripts together. However, as this is run at startup I would like script not run again if the folder exists. (Which the code does have that line in). For example a start of a new day the PC is turned on and the script runs and the user is then prompted to leave the PC for a minute untill the copy has finished and then the user can use the PC. However, if the user then logs off and then logs back in (or reboots) I would like the script to ignore the timer and the copy of the folder and just open Notepad as normal. Here is the code:

'Declare the variables. Not mandatory but a best practice
Dim dtmValue, strDate, strTime
Dim objFSO

'Create the file system object for creating folders
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Get current time in to a variable
dtmValue = Now()

'use date /time part functions to create the folder names as required
'Assuming that you are creating these folders in C:\
strDate = "C:\DATA\"& Day(dtmValue) & "_" & Month(dtmValue) & "_" & Year(dtmValue)
strTime = strDate & "\" & Hour(dtmValue) & "-" & Minute(dtmValue) & "-" & Second(dtmValue)

'Wscript.Echo strDate
'Wscript.Echo strTime

'Create the folders using objFSO
'First check if folders exists and create only they dont exist
if objFSO.FolderExists(strDate) Then
if not objFSO.FolderExists(strTime) Then
'objFSO.CreateFolder(strTime)
End If
Else
'Create Top level folder first
objFSO.CreateFolder(strDate)

'Create subfolder
'objFSO.CreateFolder(strTime)

Set FSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C\Data\1\*.*",(strDate)
objFSO.CopyFile "C\Data\1\*.*",(strDate)


Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Exec("C:\Windows\Notepad.exe")
Set objShell = Nothing


End If

Now Im not the best VB Script person but the above code does work. There are lines I have commented out but I might need them at a later date so don't worry I have left them in. (It has been used from another post on another forum (which I can show but not sure if I can link to other sites in posts on here.) Can anyone tweek this so it included the timer and the ignoring if exists part (and also tidy up the code if required)

different scenarios

1) The user logs on on a new day and the script runs and then opens Notepad
2) The user logs on on the same day (after rebooting /logging off and on) and ignores the folder copy script and opens Notepad.

Many thanks

how to fix thisr:Remote Desktop session ended becouse didn't receive any input from

$
0
0
How to fix this error:
Code:

Remote Desktop Connection: Your Remote Desktop session ended becouse the remote computer didn't receive any input from you.
I opened a rdp session then inside that rdp i opened another rdp ( here the problem,im not admin. i can't install or modifiy registries etc),after 12 min. i receive this error message:'' Idle timer expired '' i solve this with ''clickoff tool'' but now i receive the message above,is there a script or a way to solve this?
thank you!

Moving multiple items one at a time while using session variables

$
0
0
Alright, I'm new to this and am wondering how this can be done...I managed to figure out how to move singular items to a different page. What I want to do is when a user clicks a button it moves the selected item to a different page (while saving the session variable on that page so it doesn't reset (unsure as to how)), then the user can go back to the page with the products and add more (without the information on the "order form" resetting back to nothing as it were), I've looked into session variables and just can't find the answer I'm looking for. Any help would be greatly appreciated!

Thank you,

Xandler

ODBC Driver Error

$
0
0
hi All,

We are uploading excel sheet on server in Classic ASP. We are receiving below error:
-------
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Excel Driver] Reserved error (-5016); there is no message for this error.
-------
It was working find till yesterday. Window patch update day before yesterday. Find attached patch details.

configuration
Server 2008 R2
Attached Images
 

[ISSUE] Required double Login to view site properly

$
0
0
Hello, my name is Robert and I have a very weird issue with my company's web site that utilizes VBScript and Asp.net features. I don't know exactly how to word this issue so looking for solutions online have come up very short with solutions, so I thought I would try my hand here. There are two key parts to this problem that need to be addressed, so anyone that might try helping me understands some of the possible complications involved with "I don't know how to word the problem"

Storytime: I recently took a position at this company in an IT capacity. I know some IT infrastructure and systems, but going in I didn't realize how startling things would be having a different background than what the company uses (My background is in Windows server and some Linux, but the office uses nothing but Mac/Apple products. Anyhow, irrelevant) One of the things that became my responsibility was handling the web site, which included updating it from the early 1990's. I have very little experience in web design mostly because that was not my focus nor my degree. But I accepted the task and began making as many changes as I could. Over the past few months now, I have found a problem that has plagued the web site and need to find a way to fix it. The web site uses .asp as a means of populating our products via a connection to a database access file. The product pages use variables to pull information from the linked mdb files and produces items for our users to view. We do not sell from the site, so customer interaction is basic; they log into the web site using a universal password and the password grants them a few various levels of information. Some customers view the full product information, which includes pricing, where as some customers only get to view the specs of the items (no pricing)

The problem we are facing and the one I am having trouble finding a solution for is this; when a user comes to our web site, they are greeted with a login screen. They type in a 5 digit password provided to them from a sales rep and it takes them into the main portion of the site. From there they can navigate in and look at items however the password interaction within the site fails slightly. The user can navigate the entire site, see every product, but unless they go back to the login screen a second time, they see no details nor data. Essentially they can see the image of the products with their names, but unless they hit the "home" button and proceed back to the login screen, that is all the information they get. Now, once they back up to the login screen and enter in their password a second time, everything operates as normal. Since I have very little knowledge of this particular style of web design, and have very limited information about vbscript, trying to decipher the old code and find a fix to this has plagued me some 3 months. The only thing I was able to solve in that time was being able to make it so mobile users didn't have to log in every 5 minutes. (Previously, if a mobile user logged onto the site, they would be forced to log in a second time once they tried to look at a product)

So heres where things get little tricky. For confidential reasons, I cannot post the code on a whole. I can try to provide details on some of the code but I would need to know which portions are needed to be examined. What I can do is detail the path for which the code responds on the site, and it may shed some insight as to what is needed.

So when you go to our domain site, the index page has a login button that captures the info in the password field box, and passes it to the passwordfield variable. This opens into an asp page called redirect, where the asp loads information and checks passwordfield with possible outcomes (if passwordfield = a, then provide pricing, if passwordfield = b, do not provide pricing, for example) If the result is not correct, an error is passed and the user is redirected to an error screen which then directs them to a new page, login.asp (essentially a duplicate of the index page, but it uses passfield as a variable catch instead of passwordfield). When the password is correct, the user is taken to one of two home.asp pages, one for pricing-allowed users, one for no pricing (irrelevant) At this point, if this was the first time the user logged in to the site, navigating to products would reveal no information aside from the name and image of the item; no details (pricing-allowed or otherwise) is showing. If the user hits the home button at the top of any page, it will redirect them to the login.asp page as though their login time expired and force them to log a second time. This time the user gets full privileges and can navigate unhindered.

What I need to know is where, if possible, this series of variables being passed would cause this error insomuch as it would require the user to log in a second time.

Let me know if there is anything further needed that I might be able to scour the code and help facilitate a response.

Regards,
Robert

P.S. I apologize for the format of my question. As I stated its hard for me to really put together a way to discuss the problem, specifically in code, when I do not know where the issue might be. There is a lot of code in various places throughout the web site, and it would be difficult to define the entire web site and its code into a forum post.

[RESOLVED] Simple vbs regex q

$
0
0
Hi, new to vbs scripting -- can anyone pleaes let me know how to get the "34" from this string? The numbers will change but the text will always be the same.

Showing 1 to 10 of 34 entries (filtered from 432 total entries)

I assume could just get the characters that are between the 5th blank space and the 6th blank space.

Email same person multiple files

$
0
0
I am trying to create a script that can email multiple files from a single folder to the same person where each file is attached to a separate email. Can anyone help?

NJ

[RESOLVED] variable undefined objshell

$
0
0
i am making an .hta app with vbscript primarily along with using a .vbs file and two batch files.. everything is working good except after doing some fixes for other stuff; i am getting an error that objshell is undefined when attempting to write a text box to "input.txt"

"set objshell = createobject("wscript.shell")" is where the problem is.
please help i am new



HTML Code:

<script language="vbscript">
option explicit
        Const ForWriting = 2

        Dim objFSO, objFile, strFileName
        strFileName = "input.txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
       
        Set objFile = objFSO.OpenTextFile(strFileName, 2, true)
Set objshell = CreateObject("WScript.Shell")

Sub Submitarea
  Set objFile = objFSO.OpenTextFile(strFileName, 2, True)
  objfile.Write TextFile.Value
  objFile.Close
  MsgBox "Your text has been added to " & strFileName, 64, "Textarea Input"

End Sub
</script>       
        <textarea name="TextFile" id="TextFile" rows="20" cols="50"></textarea>
       
        <input type="button" value="Submit" onclick="Submitarea">

Viewing all 662 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>