Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1035219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:30:40+00:00 2026-05-16T14:30:40+00:00

I have this script that I’d like to in addition save as a xls

  • 0

I have this script that I’d like to in addition save as a xls file, also save as a .txt in the same directory, or even a different one. Can I get some guidance here?

Imports System.IO

Module Module1

 Private Property fs As Object
 Private Property BaseName As Object
 Private Property FullTargetPath As Object

Sub Main()

    Dim targetfolder As String = "C:\TEST"
    Dim sourcefolder As String = "\\10.97.8.16\c$\Checks\XMLFiles"
    Dim Searchpattern As String = String.Format("{0:MM-dd-yyyy}*.xml", Date.Today)
    Dim todaysfiles() As String = Directory.GetFiles(sourcefolder, Searchpattern)
    Dim xlApp, xlWkb
    xlApp = CreateObject("excel.application")
    fs = CreateObject("Scripting.FileSystemObject")
    Const xlnormal = 1

    'Extra Dims


    'Hide Excel
    xlApp.Visible = False

    For Each file As String In todaysfiles
        ' Excel stuff... ' 

        Dim fileName As String = IO.Path.GetFileNameWithoutExtension(file)

        ' Concatenate full path. Extension will be automatically added by Excel. ' 
        Dim fullTargetPath = IO.Path.Combine(targetfolder, fileName)

        'Process each file in SourceFolder
        ' For Each file In fs.GetFolder(SourceFolder).files
        'Open file in SourceFolder
        xlWkb = xlApp.Workbooks.Open(file)
        'Get Filename
        BaseName = fs.getbasename(file)
        'Concatenate full path. Extension will be automatically added by Excel
        fullTargetPath = targetfolder & "\" & BaseName
        'Save as XLS file into TargetFolder
        xlWkb.SaveAs(fullTargetPath, xlnormal)

        'Close the file after its done
        xlWkb.close()
    Next

    xlWkb = Nothing
    xlApp = Nothing
    fs = Nothing

    ' MsgBox("Thank you. Currently the Date is: " & Date.Today & " people like to eat chicken Every " & Date.Today.Ticks & " minutes.")


    'This is for extra code below

End Sub

End Module

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:30:41+00:00Added an answer on May 16, 2026 at 2:30 pm

    Pretty much exactly as you are doing now, but change the format in from xlnormal to xltext.

    xlWkb.SaveAs(fullTargetPath, xltext)
    

    When researching something like this I like to look around the object browser under vba editor. Look up Workbook object in this case and then the SaveAs sub to get the definition (parameters and types) then you can click on the parameter you want more information on and look it up from the help menu. I say that from memory I have not played with excel macros in years. Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this script that is meant to move a file from one folder
Well basically I have this script that takes a long time to execute and
I have this line in a useful Bash script that I haven't managed to
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
I have this script that creates a new tab in JQuery. Can you check
I have this script that works ok. Trouble is that when I make Click
I have this script that only lets users enter a single tag but I
I have this script that basically will show a product or products based on
I have this script that fetches some data from mysql and then uses echo
I have this script that collects data from users and I want to check

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.