logo
down
shadow

VBScript Opening folder to convert csv to xls


VBScript Opening folder to convert csv to xls

Content Index :

VBScript Opening folder to convert csv to xls
Tag : excel , By : msugar
Date : November 25 2020, 07:27 PM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How can I run the vbscript as the 'Administrator' but access on APPDATA folder of current logon user VBSCRIPT


Tag : vbscript , By : Mark
Date : March 29 2020, 07:55 AM
I hope this helps you . Cannot do this with a VBS alone.
You would need to create a batch file to pass this %APPDATA% environment variable into the script as Argument, then modify the VBS script to process this argument(s).
Dim sTxt
sTxt = WScript.Arguments.Count & " arguments passed into vbs:"
sTxt = sTxt & JoinArgs
wscript.echo sTxt

Function JoinArgs()
    Dim sTmp
    sTmp = ""
    For Each oArg In Wscript.Arguments
        sTmp = sTmp & vbCrLf & oArg
    Next
    JoinArgs = sTmp
End Function
@echo off
C:\SysInt\psexec.exe -u %computername%\administrator -p AccountPassword -e wscript.exe "c:\debug\vbs\test.vbs" %appdata%

Looking for a VBScript to move files older than 3 years to a new folder while keeping the folder structure


Tag : vbscript , By : fstender
Date : March 29 2020, 07:55 AM
should help you out I am looking to move files from my file server to a tape drive to save space. I need a script that will allow me to move all the files that were accessed 3 years ago or later while still keeping their folder structure.
Dim objFSO, ofolder, objStream, strSafeDate, strSafeTime, strDateTime, strLogFileName

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("scripting.filesystemobject")
Set objNet = CreateObject("WScript.NetWork")
Set FSO = CreateObject("Scripting.FileSystemObject")

strSafeDate = DatePart("yyyy",Date) & Right("0" & DatePart("m",Date), 2) & Right("0" & DatePart("d",Date), 2)
strSafeTime = Right("0" & Hour(Now), 2) & Right("0" & Minute(Now), 2) & Right("0" & Second(Now), 2)

Set strDateTime equal to a string representation of the current date and time, for use as part of a valid Windows filename

strDateTime = strSafeDate & "-" & strSafeTime

'Assemble the path and filename
strLogFileName ="Move File " & strDateTime & ".txt"
set outfile = fso.createtextfile(strLogFileName,true)
SPath = "I:\Tech Docs\"
Sdest = "I:\Test\"

ShowSubfolders FSO.GetFolder(spath)

Sub ShowSubFolders(Folder)
    CheckFolder Folder
    For Each Subfolder in Folder.SubFolders
        ShowSubFolders Subfolder
    Next
End Sub

'CheckFolder(objFSO.getFolder(SPath))

Sub CheckFolder(objCurrentFolder)
    Dim strTempL, strTempR, strSearchL, strSearchR, objNewFolder, objFile
    Const OverwriteExisting = TRUE
    currDate = Date
    dtmDate = DateAdd("d",-0,Now)
    strTargetDate = ConvDate(dtmDate)
    For Each objFile In objCurrentFolder.Files

        'Since we want to preserve the path, we've got to reconstruct it
        sAbsPath = objFile.Path
        'Swap source and destination in the path, and strip the file name
        'from the path.
        sNewPath = Replace(Replace(sAbsPath,sPath,Sdest),"\" & objFile.Name,"")
        'Here we reconstruct the path if it doesn't exist in the
        'destination with our new Sub "MakeDir"
        MakeDir sNewPath

        FileName = objFile
        'WScript.Echo FileName
        'strDate = ConvDate(objFile.DateCreated)
        strDate = ConvDate(objFile.DateLastAccessed)
        If strDate =< strTargetDate Then
            'Finally we copy the file to the sNewPath
            objFSO.MoveFile FileName, sNewPath & "\"
            outfile.writeline Filename
        End If
    Next
End Sub

Sub MakeDir(strPath)
    On Error Resume Next
        strParentPath = objFSO.GetParentFolderName(strPath)

        If Not objFSO.FolderExists(strParentPath) Then MakeDir strParentPath
        If Not objFSO.FolderExists(strPath) Then objFSO.CreateFolder strPath
    On Error Goto 0 
End Sub

Function ConvDate (sDate) 'Converts MM/DD/YYYY HH:MM:SS to string YYYYMMDD
    strModifyDay = day(sDate)
    If len(strModifyDay) < 2 Then
        strModifyDay = "0" & strModifyDay
    End If
    strModifyMonth = Month(sDate)
    If len(strModifyMonth) < 2 Then
        strModifyMonth = "0" & strModifyMonth
    End If
    strModifyYear = Year(sDate)
    ConvDate = strModifyYear & strModifyMonth & strModifyDay
End Function

VBScript - Find files in folder by string in filename, move found to different folder


Tag : vbscript , By : Fred Morrison
Date : March 29 2020, 07:55 AM
will be helpful for those in need Here you go, I fixed your if/then statements and added and if fso.fileexists:
dim fso, folder, newfolder, sourcefolder, destfolder, searchname1, searchname2, searchname3

sourcefolder = "C:\Users\...\Desktop"
destfolder = "C:\Users\...\Desktop\Sorted\"
searchname1 = "youtube"
searchname2 = "bbc"
searchname3 = "facebook"

set fso = createobject("scripting.filesystemobject") 
set folder = fso.getfolder(sourcefolder)  

if not fso.folderexists(destfolder) then
    newfolder = fso.createfolder(destfolder)
    wscript.echo "'Sorted' folder created in path: " & vbcrlf & sourcefolder
end if

for each file in folder.files
    x = fso.getbasename(file)
    if instr(lcase(x), searchname1) > 0 or instr(lcase(x), searchname2) > 0  or instr(lcase(x), searchname3) > 0 then
        if fso.fileexists(destfolder & "\" & file.name) then
            fso.deletefile destfolder & "\" & file.name, true
            fso.movefile sourcefolder & "\" & file.name, destfolder
        else
            fso.movefile sourcefolder & "\" & file.name, destfolder
        end if
    end if
next

wscript.echo "Files moved to 'Sorted' in path: " & vbcrlf & sourcefolder

itextsharp - convert page to PDF and auto save to a temp folder without opening a download dialog


Tag : chash , By : SilverRuby
Date : March 29 2020, 07:55 AM
like below fixes the issue So you want to save it on the server? Do you want to display the pdf to the browser without prompting the user to save? Perhaps the answer from this previous post on SO can help. I recall that the behavior might vary depending on the browser (IE, Chrome, Firefox, Safari). When using:
Response.AddHeader("Content-Disposition", "inline;filename=somefile.ext")
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=RequestSummaryReport.pdf");

Run convert from VBScript on all files in a folder


Tag : vbscript , By : UpperLuck
Date : March 29 2020, 07:55 AM
should help you out Here, I took a stab at it. Seems you've got a lot of excessive work for nothing. A lot of strings combining empty strings and characters... See below. Test it out making any syntax adjustments and you're all set.
The shell command execution will run as this in the current formatting....
cmd.exe /c "C:\Users\Kamil\Desktop\Nowyfolder\PDF TO TIFF imagemagick\tify\convert.exe -type bilevel -compress Group4 -pointsize 20 -draw "text 10,20 \'PropertyValue1 PropertyValue2 PropertyVAlue3 PropertyValue4 PropertyValue5\'" somefile.tif"
strfldr = "C:\Users\Kamil\Desktop\Nowyfolder\PDF TO TIFF imagemagick\tify"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colFolder = objFSO.GetFolder(strfldr)
Set colFiles = colFolder.Files
'unnecessary array removed

For Each objfile In colFiles 'Properly notate file as Object, not string
    'if instr(1, objFile.Name, ".tif", 1) <> 0 Then ShellRun(ConvertFile(objFile.Name))
    if instr(1, objFile.Name, ".tif", 1) <> 0 Then ShellExec(ConvertFile(objFile.Name))
Next

Function ConvertFile(strFileName)
    Exec = "C:\Users\Kamil\Desktop\Nowyfolder\PDF TO TIFF imagemagick\tify\convert.exe"
    TypeParam = "-type bilevel"
    CompParam = "-compress Group4"
    PsizeParam = "-pointsize 20"
    DrawParam = "-draw ""text 10,20 \'PropertyValue1 PropertyValue2 PropertyVAlue3 PropertyValue4 PropertyValue5\'"""
    Params = TypeParam & " " & CompParam & " " & PsizeParam & " " & DrawParam & " " & strFileName & " " & strFileName
    ConvertFile = """" & Exec & " " & Params & """"
    'Returns properly formatted Command string
End Function

Function ShellRun(strCommand)
    On Error Resume Next
    if NOT isObject(shell) then Set shell = CreateObject("Wscript.Shell")
    wscript.echo strcommand
    shell.run "cmd.exe /c " & strCommand, 0, true
    If Err.Number <> 0 Then
        msgbox "Error Code:" & err.Number & vbCrLf & "Error Description: " & Err.Description, 0, "Shell Command Error " & err.number & "!"
        err.clear
    End if
    on error goto 0
    Set shell = nothing
    'Executes command shell hidden - returns error code via msgbox.
End Function

Sub ShellExec(strCommand)
    ShellExecReturn = CreateObject("Wscript.Shell").Exec("cmd /c " & strCommand ).stdout.readall
    wscript.sleep 1000
    wscript.echo ShellExecReturn
End Sub
Related Posts Related QUESTIONS :
  • Excel Macro - How to automatically copy a trendline from a graph to a cell
  • Formula in Excel: Matching Year and Date
  • Remove Duplicates using vba
  • How to Write Select Query and Fetch Details to Excel |VBA|
  • bold cell based on specific value in column J
  • VBA - How to merge 2 columns while copying some data from the original row
  • Pull All Rows that Contain Same Invoice Number if Cell contains value
  • How can align text to the right using VBA, if a cell contains a specific value?
  • ActiveCell recognition below 2nd row
  • How to convert FILETIME to Date in VBA?
  • VLOOKUP can't return value more than once on a row
  • How to Open & Close multiple excel workbooks based on a range of cells
  • Excel Insists that my OpenXml file has errors
  • How to deselect only one particular item in a slicer
  • How to conditionally format cells which contain the same string of text?
  • How to get the cell position/row of a search result
  • Cannot use an If-statement with multiple conditions (AND/OR) when looping through variant array?
  • Data Validation based off multiple criteria
  • How can I list horizontal data vertically without using transpose?
  • Split full name into lastname,firstname if lastname has multiple parts (i.e. van, de)
  • can't get past block if
  • Data Validation in Userform to not allow / \ : * ? " < > | for textbox
  • How to highlight duplicates in column that are not blanks?
  • How to use vlookup in vba-excel?
  • VBA using Excel version of Find on a Word Object?
  • How to delete Excel rows containing cells with less than specific amount of characters in them?
  • How to load a PQ function from a text file
  • Fill many cells in a row with one value
  • What would be the correct way to convert a column's text into multiple columns?
  • Use a Dynamic Range in an Excel Formula
  • Finding Max/Min Without Using Array
  • autofilter erroring out
  • Fixing "Unknown runtime error" code 800A03EC in VBScript to run macro without opening Excel
  • How to access the value of a string when defining within a loop
  • How to keep formulas working when copy and pasting in Excel?
  • How to calculate the difference between max/min dates on non static pivot tables?
  • How to store row and column of excel into array (more than 1 column and 1 row)
  • Can having multiple instances of Excel open cause VBA issues?
  • Why vba is replacing SN-Sh as zeros in the Word Snapshot as 00ap00ot?
  • Excel formula to return value of cell in column A based off the relative cell value in column B
  • how to remove negative sign from a characters or text?
  • How to get the border sizes of a userform?
  • Allow two cells to depend on each other
  • Excel count rows while treating merged rows as one
  • Search for a text segment using MAX IF in Excel
  • Unable to set object VBA
  • How can I transfer to a sheet if range says "Fail" in any cell?
  • Shorten a cell, nested Ifs Excel
  • Finding the volume of a tank in VBA given the radius, height, and depth
  • Compile Error on simple VBA form and command button click code
  • Looping through Workbooks and Copy a Dynamic range to Master Workbook
  • Using .NET HashTable Return Type in VBA
  • How do I not get Run-time error '13': Type mismatch while iterating rows?
  • How to change image of a Powerpoint shape?
  • Adding character before text in Excel without using formula
  • How can I create a list of numbers that is like the following?
  • How to fix " Run-time error '380' in Excel VBA?
  • How can you repeat a number x times in a column in a continuation, in excel
  • How to delete the content of a txt file with vba?
  • How to work with more Target.Address (range)
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com