Export specific xls columns to txt











up vote
1
down vote

favorite












I like to export 2 columns from a .xls file to a txt.



Let say column C and D. Im also trying to seperate them with a _.
The .xls have several sheets and I only need data from one of them. How do you accoplish that?



This is what I have so far. I have never done anything like this before and I honestly dont know what I am doing rihgt/wrong. I get all kinds or errors and haveing a hard time figure vbs out.



Dim saveDir
set fso = CreateObject("Scripting.FileSystemObject")
set shell = CreateObject("WScript.Shell")
set objExcel = CreateObject("Excel.Application")
Set objArgs = WScript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")

set top = fso.GetFolder(shell.CurrentDirectory)
DirBase = top & "" & "jipCOPY" & ""

Set objExcel = CreateObject("Excel.application")
set objExcelBook = objExcel.Workbooks.Open(DirBase & "1.xls")
objExcel.application.visible=false
objExcel.application.displayalerts=false

Set puCols = objExcel.Range("C13","C15")
Set poCols = objExcel.Range("D13","D15")

Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("jipDATA.txt", ForWriting)
objFile.WriteLine puCols & "_" & poCols
objFile.Close


objExcel.Application.Quit
objExcel.Quit
Set objExcel = Nothing
set objExcelBook = Nothing


I'm trying to do this with a .vbs executed from a .bat.



All code is taken from this site and I tried to mod it but I cant say that it is going the right direction. Any one who could help out a bit, point me in the right direction or any thing?










share|improve this question
























  • Did you find anything posted useful? Please post feedback, vote and/or accept according to what you found.
    – sancho.s
    Jun 3 '15 at 8:48















up vote
1
down vote

favorite












I like to export 2 columns from a .xls file to a txt.



Let say column C and D. Im also trying to seperate them with a _.
The .xls have several sheets and I only need data from one of them. How do you accoplish that?



This is what I have so far. I have never done anything like this before and I honestly dont know what I am doing rihgt/wrong. I get all kinds or errors and haveing a hard time figure vbs out.



Dim saveDir
set fso = CreateObject("Scripting.FileSystemObject")
set shell = CreateObject("WScript.Shell")
set objExcel = CreateObject("Excel.Application")
Set objArgs = WScript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")

set top = fso.GetFolder(shell.CurrentDirectory)
DirBase = top & "" & "jipCOPY" & ""

Set objExcel = CreateObject("Excel.application")
set objExcelBook = objExcel.Workbooks.Open(DirBase & "1.xls")
objExcel.application.visible=false
objExcel.application.displayalerts=false

Set puCols = objExcel.Range("C13","C15")
Set poCols = objExcel.Range("D13","D15")

Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("jipDATA.txt", ForWriting)
objFile.WriteLine puCols & "_" & poCols
objFile.Close


objExcel.Application.Quit
objExcel.Quit
Set objExcel = Nothing
set objExcelBook = Nothing


I'm trying to do this with a .vbs executed from a .bat.



All code is taken from this site and I tried to mod it but I cant say that it is going the right direction. Any one who could help out a bit, point me in the right direction or any thing?










share|improve this question
























  • Did you find anything posted useful? Please post feedback, vote and/or accept according to what you found.
    – sancho.s
    Jun 3 '15 at 8:48













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I like to export 2 columns from a .xls file to a txt.



Let say column C and D. Im also trying to seperate them with a _.
The .xls have several sheets and I only need data from one of them. How do you accoplish that?



This is what I have so far. I have never done anything like this before and I honestly dont know what I am doing rihgt/wrong. I get all kinds or errors and haveing a hard time figure vbs out.



Dim saveDir
set fso = CreateObject("Scripting.FileSystemObject")
set shell = CreateObject("WScript.Shell")
set objExcel = CreateObject("Excel.Application")
Set objArgs = WScript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")

set top = fso.GetFolder(shell.CurrentDirectory)
DirBase = top & "" & "jipCOPY" & ""

Set objExcel = CreateObject("Excel.application")
set objExcelBook = objExcel.Workbooks.Open(DirBase & "1.xls")
objExcel.application.visible=false
objExcel.application.displayalerts=false

Set puCols = objExcel.Range("C13","C15")
Set poCols = objExcel.Range("D13","D15")

Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("jipDATA.txt", ForWriting)
objFile.WriteLine puCols & "_" & poCols
objFile.Close


objExcel.Application.Quit
objExcel.Quit
Set objExcel = Nothing
set objExcelBook = Nothing


I'm trying to do this with a .vbs executed from a .bat.



All code is taken from this site and I tried to mod it but I cant say that it is going the right direction. Any one who could help out a bit, point me in the right direction or any thing?










share|improve this question















I like to export 2 columns from a .xls file to a txt.



Let say column C and D. Im also trying to seperate them with a _.
The .xls have several sheets and I only need data from one of them. How do you accoplish that?



This is what I have so far. I have never done anything like this before and I honestly dont know what I am doing rihgt/wrong. I get all kinds or errors and haveing a hard time figure vbs out.



Dim saveDir
set fso = CreateObject("Scripting.FileSystemObject")
set shell = CreateObject("WScript.Shell")
set objExcel = CreateObject("Excel.Application")
Set objArgs = WScript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")

set top = fso.GetFolder(shell.CurrentDirectory)
DirBase = top & "" & "jipCOPY" & ""

Set objExcel = CreateObject("Excel.application")
set objExcelBook = objExcel.Workbooks.Open(DirBase & "1.xls")
objExcel.application.visible=false
objExcel.application.displayalerts=false

Set puCols = objExcel.Range("C13","C15")
Set poCols = objExcel.Range("D13","D15")

Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("jipDATA.txt", ForWriting)
objFile.WriteLine puCols & "_" & poCols
objFile.Close


objExcel.Application.Quit
objExcel.Quit
Set objExcel = Nothing
set objExcelBook = Nothing


I'm trying to do this with a .vbs executed from a .bat.



All code is taken from this site and I tried to mod it but I cant say that it is going the right direction. Any one who could help out a bit, point me in the right direction or any thing?







excel vbscript export






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 5:17









Cœur

17k9102140




17k9102140










asked May 22 '15 at 22:03









Moberg

61




61












  • Did you find anything posted useful? Please post feedback, vote and/or accept according to what you found.
    – sancho.s
    Jun 3 '15 at 8:48


















  • Did you find anything posted useful? Please post feedback, vote and/or accept according to what you found.
    – sancho.s
    Jun 3 '15 at 8:48
















Did you find anything posted useful? Please post feedback, vote and/or accept according to what you found.
– sancho.s
Jun 3 '15 at 8:48




Did you find anything posted useful? Please post feedback, vote and/or accept according to what you found.
– sancho.s
Jun 3 '15 at 8:48












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Your best bet is to learn how to debug. That will let you deal with each of your "all kinds or errors", or at least post which line produces each error (and specify it). Otherwise, you are bound to waiting for someone to fix the code for you, it might be unlikely.



Check How do I debug a stand-alone VBScript script? .
There are plenty of other sources.
Essential tips:




  • Place breakpoints.

  • Execute step by step

  • Inspect values of variables, with Debug.Print (in your code and in the immediate window), with Watches, etc.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f30406503%2fexport-specific-xls-columns-to-txt%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Your best bet is to learn how to debug. That will let you deal with each of your "all kinds or errors", or at least post which line produces each error (and specify it). Otherwise, you are bound to waiting for someone to fix the code for you, it might be unlikely.



    Check How do I debug a stand-alone VBScript script? .
    There are plenty of other sources.
    Essential tips:




    • Place breakpoints.

    • Execute step by step

    • Inspect values of variables, with Debug.Print (in your code and in the immediate window), with Watches, etc.






    share|improve this answer



























      up vote
      0
      down vote













      Your best bet is to learn how to debug. That will let you deal with each of your "all kinds or errors", or at least post which line produces each error (and specify it). Otherwise, you are bound to waiting for someone to fix the code for you, it might be unlikely.



      Check How do I debug a stand-alone VBScript script? .
      There are plenty of other sources.
      Essential tips:




      • Place breakpoints.

      • Execute step by step

      • Inspect values of variables, with Debug.Print (in your code and in the immediate window), with Watches, etc.






      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        Your best bet is to learn how to debug. That will let you deal with each of your "all kinds or errors", or at least post which line produces each error (and specify it). Otherwise, you are bound to waiting for someone to fix the code for you, it might be unlikely.



        Check How do I debug a stand-alone VBScript script? .
        There are plenty of other sources.
        Essential tips:




        • Place breakpoints.

        • Execute step by step

        • Inspect values of variables, with Debug.Print (in your code and in the immediate window), with Watches, etc.






        share|improve this answer














        Your best bet is to learn how to debug. That will let you deal with each of your "all kinds or errors", or at least post which line produces each error (and specify it). Otherwise, you are bound to waiting for someone to fix the code for you, it might be unlikely.



        Check How do I debug a stand-alone VBScript script? .
        There are plenty of other sources.
        Essential tips:




        • Place breakpoints.

        • Execute step by step

        • Inspect values of variables, with Debug.Print (in your code and in the immediate window), with Watches, etc.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 23 '17 at 12:21









        Community

        11




        11










        answered May 23 '15 at 3:17









        sancho.s

        6,17773587




        6,17773587






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f30406503%2fexport-specific-xls-columns-to-txt%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?