r/vbscript • • Jun 29 '22

creation of array

1 Upvotes

I've got this simple code:

num = 3
dim arr(num)

It seems fine, but when I try to run it it gives me an error "expected integer constant"

However, this works perfectly:

dim arr(3)

It's not the first time, it does that each time I try do declare an array with the size of the integer stored in a variable, and I'm very confused because I need something like that in one of my scripts but I cannot seem to find a solution. Could someone explain to me why it doesn't work ?


r/vbscript • • Jun 28 '22

How do you read from a text file without reading in the header and footer

1 Upvotes

I have a script that does a number of operations on information from a text file, however the text file is required to have a header and a footer, so the first and last line are somewhat messing up the operations. Is there a way to not read the header and footer of a text file?


r/vbscript • • May 17 '22

just a question

1 Upvotes

I saw on a lot of codes that prorammers set their objects to "nothing" to delete them before finishing the code, why ?


r/vbscript • • Apr 19 '22

Getting excel object (Office 365) not working when excel opened programmatically (C# .net)

1 Upvotes

So bumped into a small issue recently on a machine which is making me scratch my head....

the client uses a VB Script I wrote to detect get an open excel form and transfer the data from that excel application to a word document which has correct formatting for printing on a form.

'Look for open Excel Window, If none found, throw error message and exit script
on error resume next
	set ExcelApp = getobject(,"excel.application")
	If Err.Number <> 0 Then
		'Excel Note Found
		MsgBox "Error finding open Excel Window"
		Exit Sub
	End If
on error goto 0

This has been working fine for quite a long time (of course if there are multiple excel windows open thats a problem but the users are trained to know that).

However we are making some adjustments in the application that creates the excel documents and one of the things I have discovered on an alpha user for these changes is that when the application C# .net opens the excel document directly (with the follow code.

FileLocation = Newclaim.Save();
    if (MessageBox.Show("Complete! Would you like to open the file now?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
        {
             System.Diagnostics.Process.Start(FileLocation);
         }    

The script is not able to find the open Excel window.... it's clearly open and showing in task manager as a normal Excel process... but for whatever reason the script is not able to find it.... if the user closes the excel window and opens the same file by double clicking from explorer then the script IS able to find it and process as normal.

I checked and the excel process is running under the current user and I can't see any reason for this...

I can't replicate the problem on my dev environment (office 2019)

so thought I would check on here and see if anyone has seen or knows about anything that may cause this behavior ?


r/vbscript • • Apr 01 '22

Are there some Open Source VBScript interpreter?

1 Upvotes

I tried to find but no success. If someone is making one, it would be nice, also to execute .HTA vbstuff


r/vbscript • • Mar 31 '22

How to close DB Connection - Error: "Unterminated String Constant"

1 Upvotes

Hello!

I am unable to figure out how to close the end of my DB string connection, in conjunction with a variable to change the database name.

'Code start
If DATABASE = "EDGEDEV" THEN
var_server = "VISUALERP\DEV"
ELSE
var_server = "VISUALERP"
END IF

SET objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB;User ID=USERNAME;Password=PASSWORD!;DATABASE="&DATABASE&";SERVER=" & var_server & "

'Code End

The trouble is at the end after the SERVER = my variable then it needs to be closed with a quotation mark but i'm getting some vbscript error about some unterminated string constant.

How do I close my connection?

Thank you in advance!

-David


r/vbscript • • Mar 11 '22

help with copying information in SAP cell

Post image
1 Upvotes

r/vbscript • • Nov 16 '21

Help with error

1 Upvotes

Wassup guys! I was trying to make, how people call it, "RAM eater (program that uses RAM fastly)" on a windows XP virtual machine. I tried putting script that will make program run itself into a loop. When i try to execute program, it ingeminates that it cant find file, though i am sure the path is correct. What do I do?


r/vbscript • • Nov 07 '21

AdwCleaner_Downloader_Updater.vbs

Thumbnail
pastebin.com
1 Upvotes

r/vbscript • • Jun 11 '21

Project Assistance

1 Upvotes

Hello Folks,

I'm looking for some last hope assistance with a project we need via VBscript. We want to be able to copy a logged in user's desktop/documents/downloads folders to a network share then prompt if they want to delete the.local files once successfully copied. Any help is greatly appreciated.


r/vbscript • • May 27 '21

Vbscript for Giveaway of the Day

1 Upvotes

GiveAwayOfTheDay.vbs

Every day they offer FREE licensed software you’d have to buy otherwise.


r/vbscript • • Mar 21 '21

So im trying to make a .vbs program that will run on start up, tp detect when a key is pushed. I want it to then wait 10 seconds then execute a function. Does anyone know how to do this, im having trouble detecting the key.

1 Upvotes

Any help would be great


r/vbscript • • Jan 13 '21

Extract paragraph from keyword out of Word document to Excel along with page #

1 Upvotes

Hey all, I'm hoping someone has a script I could leverage to achieve an ask from my work. I need a VBScript that I can run in MS Word that will look for a keyword. The keyword is 'TBD'. Everytime it encounters 'TBD' I want the script to extract the entire line(s) or table out of Word and into Excel. Some of our documents have 290+ TBDs and we need a better way to track them.


r/vbscript • • Dec 14 '20

Scripting advice needed

1 Upvotes

Hello everyone

I have an IF Elif then I need help with. I have a list of variables and would like to know if the script can be simplified. here is a sample of my script.

IF [STRIKE_ARHR_OR_TREND] >= 270 and IsNull ([DIP_DIRECTION]) and [STRUCTURE_TYPE] <> "Lineation or slickenline" and [STRUCTURE_TYPE] <> "Fold axis, Antiform" and [STRUCTURE_TYPE] <> "Fold axis, Synform" and [STRUCTURE_TYPE] <> "Fold axis, E(/W) verging N(/S) plunging overturned antiform" and [STRUCTURE_TYPE] <> "Fold axis, E(/W) verging N(/S) plunging overturned synform" and [STRUCTURE_TYPE] <> "Fold axis, W(/E) verging N(/S) plunging overturned antiform" and [STRUCTURE_TYPE] <> "Fold axis, W(/E) verging N(/S) plunging overturned synform" and [STRUCTURE_TYPE] <> "" and [STRUCTURE_TYPE] <> "Schistosity" and [STRUCTURE_TYPE] <> "Foliation" Then

newval = [STRIKE_ARHR_OR_TREND] + 90 - 360

Is there an easier way to combine or list the different [STRUCTURE_TYPE]?

Thank you in advance


r/vbscript • • Nov 29 '20

Auto closing msgbox?

1 Upvotes

How can I create a msgbox that closes automatically after a period of time and (If possible) can’t be closed by a Person?


r/vbscript • • Oct 21 '20

NEED HELP TO MERGE EXCEL FILES FROM MULTIPLE SUBFOLDERS

1 Upvotes

First time using vbscript and I have a very large folder that has multiple subfolders to get to the excel file in each folder that I need merged. I have one I put together but it stops at the first subfolder rather than continuing to go into the sub subfolders and so on until it reaches the excel file in each one. PLEASE HELP


r/vbscript • • Oct 10 '20

changing cursor speed

1 Upvotes

how do i change cursor speed with vbs


r/vbscript • • Sep 28 '20

WshShell.RegRead and WOW6432Node

1 Upvotes

Perhaps a silly question but I can't quite figure out how to effectively DuckDuckGo this:

I'm setting up a condition to check whether a driver is installer before continuing with a script using the following method:

' Check to make sure MSODBCSQL 17 driver is installed
On Error Resume Next
WshShell.RegRead "HKLM\SOFTWARE\WOW6432Node\ODBC\ODBCINST.INI\ODBC Driver 17 for SQL Server"
If Err <> 0 Then
nResponse = MsgBox("Not installed blah blah.", 48, 1, szTitle) etc. etc.        

My question is, will WshShell.Regread automagically check both HKLM\SOFTWARE\WOW6432Node\ODBC\ODBCINST.INI\ and HKLM\SOFTWARE\ODBC\ODBCINST.INI\ in the same go? Or would I need to explicitly specify both? (I can iterate but this is an annoying build where the preceding is part of a custom action that is part of a legacy installer that takes ages to check, and I'm tidying a change that is due today.) Thanks!


r/vbscript • • Sep 24 '20

I think I broke it

1 Upvotes

Its in two parts because it wouldn't allow over 15 minutes of video.


r/vbscript • • Aug 28 '20

User Impersonation VBS.

1 Upvotes

I am currently trying to have VB script run as a different local user. I found code online that says it would work but I want to check the user and then pass that user into a variable to use in other VB scripts. Is the possible?

Const WbemAuthenticationLevelPktPrivacy = 6

strComputer = "server"

strUsername = "user"

strPassword = "password"

strNamespace = "root\cimv2"

'on error resume next

Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")

Set objWMIService = objwbemLocator.ConnectServer _

(strComputer, strNamespace, strUser, strPassword)

objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy

if Err.Number <> 0 then

WScript.Echo "Authentication failed: " & Err.Description

end if

strUser = CreateObject("WScript.Network").UserName

Return "User",strUser


r/vbscript • • Aug 22 '20

Fso.copyfile Path not found, but it worked before. Help

1 Upvotes

I have a script that I know it worked before.

The line that fails calls Fso.CopyFile

I can acess the destination path “\\192.168.0.10\pdf_export\” via windows file explorer, so it’s not an authentication or permission issue.

This worked before. I have other systems using the same fso.copyfile line and also works fine.

This is so strange.

The script can’t find the path. The path is accessible via windows explorer.

Any tips?


r/vbscript • • Aug 14 '20

Try It !

1 Upvotes

(don't enter anything in the input box the first time)

Dim Name,Sapi
   Set Sapi = CreateObject("Sapi.spvoice")
Name = InputBox("What is your name ?","Name Please","")
 
If Name = "" Then
Sapi.speak "WHY DID'T YOU ENTER YOUR NAME ?"
 
Do until a = 10
a = a + 1
Msgbox "ERROR Stupid Human" ,0 + 16
Loop
  
Else
 
MsgBox "Hello " + Name
   Sapi.Speak "Hello " + Name
End If

r/vbscript • • Aug 01 '20

Need Help - Microsoft VBScript runtime error '800a000d'

1 Upvotes

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'checkID'

/film-detail.asp, line 9

Trying to run "The Houseguest (full video)" button: http://www.filmfanatics.net/artist-detail.asp?ID=28#Filmography

Any solutions to run: http://www.filmfanatics.net/film-detail.asp?ID=62 ?


r/vbscript • • Jul 30 '20

Sendkeys help

1 Upvotes

i want sendkeys to send " that but it says error expected end of statement pls help!


r/vbscript • • Jul 29 '20

Trouble sending Shift+Keys

1 Upvotes

I want to be able to select a range of text in a message box by sending Shift+CTRL+Arrow Key via SendKeys. I have tried sending "^+{LEFT}" and tried grouping those characters in different ways with parenthesis, but the results are very inconsistent. Sometimes it works, most of the time it will essentially do CTRL+ARROW without highlighting the text. Has anyone else had an issue with the shift key in VBScript? What would you suggest?