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

Error Messages Received

$
0
0
Dear Friends,

I am having some trouble clearing the attached 6 error-messages. I have also attached the script associated to the errors.

Does anyone have a idea how to clear them ?

Many thanks in advance.

Slds,
Attached Images
 
Attached Files

Restart Modem Script help

$
0
0
Basically here is the solution I'm looking for.
I want to be able to have Windows 7 detect when it doesn't get an IP from DHCP and run a script.
So I think I can use Task Scheduler to do this but need some help and I have a semi written script that doesn't seem to be working but maybe someone on here can help.
Basically what I need it to do is once the task scheduler detects it doesn't have an IP from DHCP and gets a 169.x.x.x IP address the script runs and then changes to a static IP, then telnet into the modem and run the reset command then then change back to DHCP and renew the IP.

Here is what I have so far but it keeps getting stuck when it goes to to the modem and maybe because I'm opening something twice because 2 CMD black boxes come up and when it logs into the modem it doesn't work right. If I run the restart modem script by itself it works fine just not with all this other stuff attached to it.
Set obj = CreateObject("WScript.Shell")
obj.run"cmd"
WScript.Sleep 500

obj.SendKeys"telnet 192.168.100.1"
obj.SendKeys("{Enter}")
WScript.Sleep 500

obj.SendKeys"root" 'telnet username
obj.SendKeys("{Enter}")
WScript.Sleep 500

obj.SendKeys"root" 'telnet password
obj.SendKeys("{Enter}")
obj.SendKeys"reset"
obj.SendKeys("{Enter}")
Wscript.Sleep 500


Dim oShell : Set oShell = CreateObject("WScript.Shell")

' Kill telnet and cmd '
oShell.Run "taskkill /im telnet.exe", , True
oShell.Run "taskkill /im cmd.exe", , True
Wscript.Sleep 500

So here is the script that restarts the modem and works just fine if I run it. But the problem is that if the computer can't get an IP then this script will fail because it can't telnet to 192.168.100.1 so it needs to change the IP to a static IP of 192.168.100.11 subnet 255.255.255.0 gateway 192.168.100.1 in order for it to be able to telnet.
Once it has static IP it can then run the above part.
Then when it's done resetting the modem it should then go back to DHCP.

Hope someone can help me.
Thanks
Brad

Add SQL Parameters via VBScript

$
0
0
Can someone please tell me what's wrong with the following code? It's erroring on the CreateParameter steps:

Set cnRRIPasswordChange = Server.CreateObject("ADODB.Connection")
Set cmdUser = Server.CreateObject("ADODB.Command")

cnRRIPasswordChange.Open Application("conn_string")

cmdUser.ActiveConnection = cnRRIPasswordChange
cmdUser.CommandType = 4 'adCmdStoredProc
cmdUser.CommandText = "sp_WS_UpdatePassword"

cmdUser.Parameters.Append cmdUser.CreateParameter("returnValue", adInteger, adParamReturnValue)
cmdUser.Parameters.Append cmdUser.CreateParameter("@nUserId", adInteger, adParamInput, , objUserLookUp(nUserId"))
cmdUser.Parameters.Append cmdUser.CreateParameter("@cPwdNew", adVarChar, adParamInput, 25, Request("password"))
' cmdUser.Execute

System process (dllhost) not being killed properly

$
0
0
Hi, I have this small script that should kill dllhost (yes i know this is not an elegant solution and shouldn't be done this way), but its only for a few months time before this server is retired. So we are using windows 2000 and we need to kill dllhost when it exceeds certain amount of memory usage, the script calculates the memory correctly and retrieves all the process as well with their PID, however they are not being killed, what should i change??

Code:

Option Explicit
Dim objWMIService, objProcess, objFSO, objTextFile
dim colProcess,colServices, colItems
dim objItem, objService, objLoc
Dim strComputer, strProcessKill, strProcessMem
Dim memLimit, processMem
Dim mustKill

strComputer = "."
strProcessKill = "'DLLHOST.EXE'"
strProcessMem = "'DLLHOST'"
memLimit = 10000
mustKill = 0


Set objLoc = createobject("wbemscripting.swbemlocator")
objLoc.Security_.privileges.addasstring "sedebugprivilege", true

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = " & strProcessKill )
dim intRC
For Each objProcess in colProcess
    msgbox "El pid es..." & ObjProcess.ProcessId

    processMem = objProcess.WorkingSetSize/1024
    msgbox "El size es " & processMem
                If processMem >= memLimit Then
                  MsgBox "pasa de " & memLimit & " Kb"
      mustKill = 1
                Else
                  MsgBox "es menor " & memLimit & " Kb"
                End If   
    if mustKill = 1 then
        msgbox "voy a matarlo"
    objProcess.Terminate()


if intRC = 0 Then
          msgbox "Successfully killed process."
        else
          msgbox "Could not kill process. Error code: " & intRC
        end if
    end if
Next


Const ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\informe_dllhost.txt", ForAppending, True)

if mustKill = 1 then   
    objTextFile.WriteLine(now & vbnewline & " El proceso se ha matado con " & processMem & " Kb" & vbnewline & vbNewLine)
end if

objTextFile.Close

WScript.Quit

thank you!

Need a little help with creating a pivot table using VBScript.

$
0
0
I hope someone can help me. I have a VBScript program to read a flat delimited file into Excel and then try to create a pivot table.

My data looks a bit like this:
Segment Amount 1 Amount 2
Corp 100.00 100.00
Elect 200.00 200.00
Corp 100.00 0.00
Elect 100.00 50.00

I want to see
Segment Sum of Amount 1 Sum of Amount 2
Corp 200.00 100.00
Elect 300.00 250.00

I get

Segment
Corp Sum of Amount 1 200.00
Sum of Amount 2 100.00

Elect Sum of Amount 1 300.00
Sum of Amount 2 250.00

I've tried recording a macro in Excel and using the code, but it doesn't work, Help!

Here is my code I know it's not complete, but I wanted to get through the pivot table section first to see what it looks like.

'Option explicit
Const ForReading = 1
Dim FSOFOLDER, Folder, FileList, File, objFSOFILEREAD, objFileRead, objFSOFILE, objFile
Dim objTestFILE, objTfile, fExtension, fName
Dim strContents, TranArray, infolder, outfolder, today, modDate, modMonth, modYear
Dim FieldCount, NstrContents, I
Dim objExcel
Dim objWorkbook
Dim objWorkSheet
Dim RecCount, objRange
Dim Count
Dim Destination
Const xlRowField=1
Const xlColumnField=2
Const xlSum = -4157

infolder = "C:\Users\E0054211\Documents\Credits Scorecard\Scorecard Details\"
outfolder = "C:\Users\E0054211\Documents\Credits Scorecard\Scorecard Details\"
'infolder = "C:\Sales\"
'outfolder = "C:\Sales\Sales-Ledger\"

today = Date()
modDate = DateAdd("m",-1,today)
modMonth = MonthName(DatePart("m", modDate),True)
modYear = Mid(modDate,(InStrRev(modDate,"/")+1),4)

'Create new Excel File

Set FSOFOLDER = CreateObject("Scripting.FileSystemObject" ;)
Set objFSOFILEREAD = CreateObject("Scripting.FileSystemObject" ;)
Set Folder = FSOFOLDER.GetFolder(infolder)
Set FileList = Folder.Files
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Add
'objExcel.Visible = False
objExcel.Visible = True
objExcel.Sheets.Add.name = "Scorecard Detail"
'Set objWorkbook = objExcel.Workbooks.Add
'Set objWorksheet= ojbExcel.Sheets.Add.name = "Scorecard Detail"

For Each File In FileList
fExtension = FSOFOLDER.GetExtensionName(File.Name)
fExtension = LCase(fExtension)

If fExtension = "csv" Then
'Set objFSOFILE = CreateObject("Scripting.FileSystemObject" ;)
'Set objFSOFILEREAD = CreateObject("Scripting.FileSystemObject" ;)
Set objFileRead = objFSOFILEREAD.OpenTextFile(File.path, ForReading)

FilRecCount = 1
RecCount = 1
'DefHeadings
SetColFMT
'LastPlant = "Division_Number"

Do While RecCount < 100
'Do While Not objfileread.AtEndOfStream
strContents = objFileRead.ReadLine
strContents = Replace(strContents,""""," ;")
TranArray = Split(strContents,",",-1)
FieldCount = UBound(TranArray)
Set Destination = objExcel.ActiveSheet.Range("A" & RecCount & ": AF" & RecCount).Resize
Destination.Value = TranArray
RecCount = RecCount + 1
Loop
End if
Next
RecCount= RecCount - 1
'objFileRead.Close

objExcel.Sheets.Add.name = "Summary"
objExcel.sheets("Scorecard Detail").select
objExcel.Columns("A:AF").select
objExcel.ActiveSheet.PivotTableWizard SourceType=xlDatabase,objExcel.Range("A1:AF&q uot; & RecCount),"Summary!R1C1","Scorecard Detail"
objExcel.ActiveSheet.PivotTables("Scorecard Detail").PivotFields("Sector").Orie ntation = 1
objExcel.ActiveSheet.PivotTables("Scorecard Detail").PivotFields("Functional Open Amount in USD").Orientation = xlColumnField
objExcel.ActiveSheet.PivotTables("Scorecard Detail").AddDataField objExcel.ActiveSheet.PivotTables("Scorecard Detail").PivotFields("Functional Open Amount in USD"), "Sum of Open Amount in USD", xlSum
objExcel.ActiveSheet.PivotTables("Scorecard Detail").PivotFields("Functional Open Amount in USD").NumberFormat = "$#,##0.00"
objExcel.ActiveSheet.PivotTables("Scorecard Detail").PivotFields("Functional AGE < 12 MO in USD").Orientation = xlColumnField
objExcel.ActiveSheet.PivotTables("Scorecard Detail").AddDataField objExcel.ActiveSheet.PivotTables("Scorecard Detail").PivotFields("Functional AGE < 12 MO in USD"), "Sum of Functional AGE < 12 MO in USD", xlSum
objExcel.ActiveSheet.PivotTables("Scorecard Detail").PivotFields("Functional Open Amount in USD").NumberFormat = "$#,##0.00"
With objExcel.ActiveSheet.PivotTables("Scorecard Detail").DataPivotField.NumberFormat = "$#,##0.00" '.Orientation = xlColumnField
End With

'********************************************************
' Formats various Cells
Sub SetColFMT
objExcel.Columns("A:N").Select 'set A to M as text
objExcel.Selection.NumberFormat = "@"
objExcel.Columns("A:N").ColumnWidth = 9.00
objExcel.Columns("G:G").ColumnWidth = 45.00
objExcel.Columns("K:K").ColumnWidth = 15.00
objExcel.Columns("L:L").ColumnWidth = 19.00
objExcel.Columns("M:M").ColumnWidth = 21.00
objExcel.Columns("O:AF").Select 'Set N to AF as formatted amount
objExcel.Selection.NumberFormat = "$#,##0.00"
objExcel.Columns("O:AF").ColumnWidth = 29.00



End Sub

Unable to use C# COM component in Classic asp page

$
0
0
Hi All,

I have developed a C# COM component and registered successfully with regsvcs. I can use this component in VB6 and able to run the VB6 application with out any issues. But when I am trying to run with asp page it gives error as "An unhandled exception (006 asp 0177 server.createobject failed ~800401f3) occured in iisexpress.exe [7280]" at the Set obj = Server.CreateObject("CsharpLibrary.Class") in the asp page.

Note:
C# component developed in VS2013 and asp page also running in VS2013.

making a url button, having problems

$
0
0
Hello Im new to this forum so im sorry if this is posted in the wrong place. I made a web browser in vb using visual studio 2013, but im having a problem (more of a 1st world problem type thing). im trying to take this part of the code,

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
WebBrowser1.GoHome()
End Sub

and replace the .GoHome() with some sort of link that will take me to google whenever I click on the button that this code is written for, but nomatter what i try i cant get anything to work, i started vb 2hrs ago so its probably an easy fix that im missing. The reason that I want to change this is because the .GoHome() links to a weird 3rd party search engine, not google. If you can find a way to make the home page that .GoHome() links to be google then that would work aswell.

:):thumb: thanks for any help :thumb::)

Help with Excel VBA to VBS

$
0
0
Can anyone help me with getting this VBA code to work in VBS? I have an excel macro that works great. It will take All data in column A and copy it to another worksheet but that X amount of rows and copy to columns. The data in column A repeats, for example every 6 row. the macro will take every 6 rows and copy to 6 columns on another worksheet. I have been trying to get this to work in VBS but I am stuck.
Here is the VBA code:
Code:

For i = 1 To rngOrig.Count Step addressRows
With wsOutput
For j = 1 To addressRows
.Cells(Rows.Count, j).End(xlUp).Offset(1, 0) _
= rngOrig.Cells(i + j - 1, 1)

Here is the latest VBS code that just does not work.
Code:

For i = 1 To objrngOrig.Count Step objaddressRows
With objOutput
  For j = 1 To objaddressRows
        objExcel.Worksheets("Output Data").Cells(Count +1, j).End(xlUp).Value = objExcel.Worksheets("Temp").Cells(i + j - 1, 1).Value
  Next
  End With
Next

It will loop thru all the data but does not copy. This is just a small part to the code but is where I am stuck.
Any help would be great! Thank you

ASP Datagrid - numbers being sorted like text

$
0
0
I have an ASP datagrid which was some columns that contain numbers. However, when I sort, it's sorting them alphabetically. For example:

0
1
10
2
23
30

How can I get it to sort them as numbers?

The column is defined like this:
Code:

<asp:BoundColumn DataField="RenewalCountdown" SortExpression="RenewalCountdown" HeaderText="Renewal Countdown">
    <HeaderStyle Font-Bold="True" HorizontalAlign="Left" Width="10%" CssClass="table_header_background"></HeaderStyle>
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Top"></ItemStyle>
</asp:BoundColumn>

Thanks in advance...

[RESOLVED] Unable to use C# COM component in Classic asp page

$
0
0
Hi All,

I have developed a C# COM component and registered successfully with regsvcs. I can use this component in VB6 and able to run the VB6 application with out any issues. But when I am trying to run with asp page it gives error as "An unhandled exception (006 asp 0177 server.createobject failed ~800401f3) occured in iisexpress.exe [7280]" at the Set obj = Server.CreateObject("CsharpLibrary.Class") in the asp page.

Note:
C# component developed in VS2013 and asp page also running in VS2013.

Expose C# List to COM Interop and access it from classic asp

$
0
0
Hi,
I have developed a C# COM Component which will return a List<classname> as result. But not able to read this from classic asp. Please help me to sort out this issue.

Simple way to copy text from telnet and cmd window

$
0
0
Hello,
I am looking for form help, This is what i am trying to do:

Create a VB script to;
open the windows telnet client, connect to a telnet server, browse to a certain directory, list the folders in that directory, copy that list from the telnet window, paste to excel for filtering.
I am new to VB and programing, the below code is getting me as far as listing the folders in the telnet window.

Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "telnet"
WScript.Sleep 3000

oShell.Sendkeys "open serverIP~"

WScript.Sleep 2000
oShell.Sendkeys "user~"
WScript.Sleep 1000
oShell.Sendkeys "password~"
WScript.Sleep 1000

oShell.Sendkeys "cd /directory path ~"
oShell.Sendkeys "ls -1 | sort~"
'WScript.Sleep 20000

oShell.Sendkeys "% ( )" 'these lines are supposed to open the telnet menu to highlight and copy all text in the console, but the alt is not working
oShell.Sendkeys "es" 'so the menu never opens, if you try same with notepad it does work fine


if you manually press Alt+Spacebar then es you end up with all text highlighted no problem, it just wont work in the script for some reason.

this is for my work and there are lots of restrictions around what client is used so i have to stick with the windows telnet client
i can also use ftp but i am running into the same alt + spacebar problem in the cmd window also when trying to copy the text

Does anyone know why this does not work, Or is there a better but still simple way i can do the task I am trying to do?

I currently do this task manually about 15 times per day
Any help would be much appreciated.

Having Trouble Getting VBS Script to Fully Run. HELP

$
0
0
'Create name and age variables
name = ""
ageStr = ""

'Prompt User For Name and Age
WScript.StdOut.Write("Please Enter your Full Name...............")
name = Wscript.StdIn.ReadLine()
WScript.StdOut.WriteLine() 'Skip 1 line
Wscript.StdOut.Write("Please Enter Your Age.............")
ageStr=Wscript.StdIN.ReadLine()
'Calculate Age+10 and assign to ageStr10
ageStr10 = CStr( CInt(ageStr)+10 )


'Display Name and Age Values
Wscript.StdOut.WriteBlankLines(2) 'Skip 2 lines
WScript.StdOut.WriteLine("Your Name is " & vbTab & vbTab & name)
WScript.StdOut.WriteLine("Your Age is " & vbTab & vbTab & ageStr)
WScript.StdOut.WriteLine(vbCrLf & "Your Age in 10 Years is ....... " & ageStr10 & vbCrLf)
Wscript.StdOut.WriteLine("End of Program")

VBScripting Idea Need help starting

$
0
0
I want to create a script using that will automatically run everyday, than execute excel and a webpage. I also want it to give a pop up message saying with a Good morning quote. The thing I need help with is finding the script to getting a VBS cript to run at an certain time everyday. I did my research and found that there are daily time trigger and the example shows (const TriggerTypeTime = 1const TriggerTypeTime = 1) but my question here how would I express the time as 10:00 PM and would just this make it run everyday at that time.



Thanks for the help I'm going to be very active in learn here.
Please bare with me.

Finishing my script but need help

$
0
0
So as explained before I'm working on a script that automatically exe at 8am. I'm almost finish but I need some help.

1. I need my msgbox to only display for 30 seconds.

2. Question: Can you timeout for 8 hours? If So how?

3. A Timeout between The shutdown and The Abort (30seconds).

4. Do You Think anything is Missing?



If anyone can help me I would Highly Thankful:

Script:

'Daily Greeting with Date and Time
SDateTime = WeekdayName(Weekday(Date)) & ", " & MonthName(Month(Date()), False) & " " & Day(Date ()) & ", " & Year(Date())
greet = "Good Morning Today is "
msgbox greet & SDateTime


'IP Information
Dim IP_Address : IP_Address = GetIP()
Dim objNet
Dim IPFound
On Error Resume Next
Set objNet = CreateObject("WScript.NetWork")

Dim strInfo
Dim strCommand

strInfo = "Computer Name = " & objNet.ComputerName

MsgBox "IP Address = " & IP_Address & vbCRLF & strInfo, 0, "WorkStation Information"



Function GetIP()
Dim ws : Set ws = CreateObject("WScript.Shell")
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
Dim ThisLine, IP
If ws.Environment("SYSTEM")("OS") = "" Then
ws.run "winipcfg /batch " & TmpFile, 0, True
Else
ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
End If
With fso.GetFile(TmpFile).OpenAsTextStream
Do While NOT .AtEndOfStream and IPFound = 0
ThisLine = .ReadLine
If InStr(ThisLine, "IPv4 Address") or inStr(Thisline, "IP Address") <> 0 Then
IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
IPFound = 1
End If
Loop
.Close
End With
If IP <> "" Then
If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
End If
GetIP = IP
fso.GetFile(TmpFile).Delete
Set fso = Nothing
Set ws = Nothing
End Function

Dim iURL
Dim objShell

iURL = "www.time.gov"

set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "chrome.exe", iURL, "", "", 1

'After 8hour Sleep

msgbox "Save All Work System Shuting Down In 2 Minutes"

Shutdown /s /t 120 /c
'Time Out for 30 seconds

Shutdown /a




Thank You In Advance
CollegeGuy215

reading string from wix custom action with VB script problem

$
0
0
Hello.

I am building an installer in Wix, and it all works just fine except the part with my VB script. what needs to happen is the following:

1) user is prompted to fill in the MachineID.
2) installer continues by pressing next.
3) after installation the script is silently being called via a custom action.
4) the script retrieves the value from the installer and changes the selected text.

that is the idea, however it isn't working on the VB script side. the part in WIX is sorted out as I already had some help with it, so that part should be alright.

Code from the WIX installer:

Code:

<ComponentGroup Id ="DLL" Directory ="INSTALLFOLDER">
      <Component Id ="StringTransfer" Guid ="{479947FA-C324-411C-9B98-083E79C116CB}">
        <File Id ="StringTransfer" KeyPath="yes" Source="C:\Users\fjansen\Documents\Visual Studio 2015\Projects\String Transfer\Data Transfer\obj\x86\Debug\DataTransfer.CA.dll" />
      </Component>
    </ComponentGroup>
   
    <Binary Id="StringTransfer" SourceFile="C:\Users\fjansen\Documents\Visual Studio 2015\Projects\String Transfer\Data Transfer\obj\x86\Debug\DataTransfer.CA.dll" />
   
      <CustomAction
          Id="SetProperties"
          Property="ValueAdaptionScript"
          HideTarget="yes"
          Value="[MachineIdNumber]"
        />

      <CustomAction
          Id="ValueAdaptionScript"
          BinaryKey="StringTransfer"
          DllEntry="CustomAction1"
          Execute="deferred"
          Impersonate="no"
          Return="check"
        />

      <InstallExecuteSequence>
        <Custom Action="SetProperties" Before="ValueAdaptionScript" />
        <Custom Action="ValueAdaptionScript" Before="InstallFinalize">NOT REMOVE="ALL"</Custom>
      </InstallExecuteSequence>

in my Vb script I have the following code:

Code:

Public Class CustomActions
    Private Shared Property ValueAdaptionScript As String

    <CustomAction()>
    Public Shared Function CustomAction1(ByVal session As Session) As ActionResult
        session.Log("Begin CustomAction1")

        Dim MachineID As String = [ValueAdaptionScript]
        My.Computer.FileSystem.WriteAllText("C:\Program Files\MMI\dbcmmi.ini", My.Computer.FileSystem.ReadAllText("C:\Program Files\MMI\dbcmmi.ini").Replace("DE987654", [MachineID]), False)

        Return ActionResult.Success
    End Function

End Class

I do know that I need to do something with CustomActionData, bud that is prety much it. I looked it up on the Microsft website and a ton of other websites for some extra information bud I just don't seem to be able to get it working. I am not sure if it doesnt get the value from the installer or that the problem is in my script.

all the help would be appreciated,
thanks in advance,

F.J

Compare Textbox values

$
0
0
I have to textboxes that I want to compare so I can have a message box alert the user to incorrectly entered values.

I can't seem to get the compare to work.

textbox1 > textbox2

This is what I have:

Dim NTGvar, NTPvar As Variant

NTGvar = textbox1
NTPvar = textbox2

If NTGvar > NTPvar Then
MsgBox "Number of Gear teeth can not be less than teeth in Pinion", vbInformation + vbOKOnly, "Number of Teeth Error"

Thanks for the assist
David

Using vbYesNo in MsgBox

$
0
0
Hello,

I am performing a comparison below and would like to incorporate the vbyesNo. When clicking on yes I would like for the event to continue and No to exit the sub. Been trying different things with no success.

NTGwarn = CDbl(NTG)
NTPwarn = CDbl(NTP)

If NTGwarn < NTPwarn Then
MsgBox "Number of teeth in Gear are less than teeth in Pinion. Do you want to continue?", vbYesNo, "Number of Teeth Error"

NTG.SetFocus
Exit Sub

End If

TIA
David

Outlook macro script problem

$
0
0
Hi. I have put together the below script for batch printing email pdf attachments. I get hundreds of emails which all have the same name as the attachment "Tax Invoice" which is why I have inserted the incrementer option to save each attachment as "Tax Invoice1,2,3 etc". My problem is when I run the macro it doesn't print all the emails at once, only maybe half at a time and then when I go to run it again it starts the number sequence again from 1,but since there is a file already named this it won't print. Is there something in my script that is stoping the macro from primitive the all the emails?

Public Sub PrintAttachments()
Dim Inbox As MAPIFolder
Dim Item As MailItem
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Dim Filenameincrementer As Integer
Filenameincrementer = 1


Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders.Item("..To Print")
Set Printed = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders.Item(".Printed")

For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
FileName = "C:\Temp\" & Atmt.FileName & Filenameincrementer
Atmt.SaveAsFile FileName
Shell """C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"" /h /p """ + FileName + """", vbHide
Filenameincrementer = Filenameincrementer + 1
Next
Item.Move Printed
Next

Set Inbox = Nothing
End Sub

String for SQL Statement

$
0
0
Hi Everyone, I'm new to aspx & VB script & writing a SQL statement in vb script.
I'm executing a query against a db & write the output to an XML file.
When my query is a simple select like sS = " SELECT * from TABLE " then my code is ok and the XML is being generated.
(sS declared as Dim Ss String)

But when I assign my string sS = " SELECT * from TABLE where cola = "''x''" " I get an error stating: SQL command not properly ended (Oracle database)

I've tried all possibilities with double quotes, single quotes etc for the value x in my query but no success. Any idea how to properly enclose the quotes for a string value ?

Thanks in advance.
Viewing all 702 articles
Browse latest View live


Latest Images

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