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?
excel vbscript export
add a comment |
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?
excel vbscript export
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
add a comment |
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?
excel vbscript export
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
excel vbscript export
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited May 23 '17 at 12:21
Community♦
11
11
answered May 23 '15 at 3:17
sancho.s
6,17773587
6,17773587
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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