Hi Ashish, I want to open the excel file & then convert to text.
Can I add this code within my macro code? On Mon, Feb 23, 2015 at 5:32 PM, ashish koul <koul.ash...@gmail.com> wrote: > Option Explicit > Sub export_range_delimit() > > Dim arr As Variant > Dim fs As Object > Dim delimittxt > Dim i As Long > Dim j As Long > Dim line As String > Dim rng As Range > Dim delimittype As String > delimittype = "," > > Set fs = CreateObject("Scripting.FileSystemObject") > Set delimittxt = fs.CreateTextFile("C:\Users\xx\Desktop\" & > "delimit.txt", True) > Set rng = Sheet1.Range("a1:b17") > arr = rng > For j = LBound(arr) To UBound(arr) > line = "" > For i = 1 To rng.Columns.Count > line = line & delimittype & arr(j, i) > Next > delimittxt.WriteLine Right(line, Len(line) - 1) > Next > delimittxt.Close > Set delimittxt = Nothing > Set fs = Nothing > > End Sub > > > see if it helps > > > On Mon, Feb 23, 2015 at 9:47 PM, ashish koul <koul.ash...@gmail.com> > wrote: > >> Do you wanna export range in comma delimit text file?. >> >> On Mon, Feb 23, 2015 at 9:38 PM, Muneera Shabana < >> muneera.shab...@gmail.com> wrote: >> >>> Hello there, >>> >>> I have written a macro to convert xls files to text file, however I have >>> 2 problems here: >>> 1. My code doesnot show xlsx format to pick up from the source folder >>> 2. I am not sure when to add the code to have delimiter "comma" in my >>> text file. >>> >>> I am not an expert, so seeking support from you guys, please help!! >>> >>> >>> >>> >>> Sub XLS_to_TXT() >>> >>> Dim wb As Workbook >>> Dim SourcePath As String >>> Dim strFile As String, strDir As String >>> Dim newpath As String >>> Dim k >>> Dim q >>> Dim j >>> >>> Set j = Application.FileDialog(msoFileDialogFolderPicker) >>> >>> j.Show >>> >>> SourcePath = j.SelectedItems(1) >>> >>> SourcePath = SourcePath & "\" >>> >>> '// SourcePath = "H:\Macros\" >>> >>> strFile = Dir(SourcePath & "*.xlsx") >>> >>> Do While strFile <> "" >>> >>> Set wb = Workbooks.Open(Filename:=SourcePath & strFile, Local:=True) >>> >>> newpath = "H:\Macros\csv\" >>> >>> k = Replace(wb.FullName, ".xlsx", ".txt") >>> >>> q = Replace(k, SourcePath, newpath) >>> >>> wb.SaveAs q >>> >>> wb.Close True >>> >>> Set wb = Nothing >>> >>> strFile = Dir >>> >>> Loop >>> >>> MsgBox "The files are successfully converted into text format & placed >>> in target folder" >>> >>> Application.Wait (Now + TimeValue("00:00:02")) >>> >>> ActiveWorkbook.FollowHyperlink newpath >>> >>> End Sub >>> >>> >>> >>> >>> -- >>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? >>> It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >>> https://www.facebook.com/discussexcel >>> >>> FORUM RULES >>> >>> 1) Use concise, accurate thread titles. Poor thread titles, like Please >>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice >>> will not get quick attention or may not be answered. >>> 2) Don't post a question in the thread of another member. >>> 3) Don't post questions regarding breaking or bypassing any security >>> measure. >>> 4) Acknowledge the responses you receive, good or bad. >>> 5) Jobs posting is not allowed. >>> 6) Sharing copyrighted material and their links is not allowed. >>> >>> NOTE : Don't ever post confidential data in a workbook. Forum owners and >>> members are not responsible for any loss. >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "MS EXCEL AND VBA MACROS" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to excel-macros+unsubscr...@googlegroups.com. >>> To post to this group, send email to excel-macros@googlegroups.com. >>> Visit this group at http://groups.google.com/group/excel-macros. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> *Regards* >> >> *Ashish Koul* >> >> >> *Visit* >> http://www.excelvbamacros.in >> Like Us on Facebook <https://www.facebook.com/excelvbacodes> >> Join Us on Facebook <http://www.facebook.com/groups/163491717053198/> >> >> >> P Before printing, think about the environment. >> >> >> > > > > -- > *Regards* > > *Ashish Koul* > > > *Visit* > http://www.excelvbamacros.in > Like Us on Facebook <https://www.facebook.com/excelvbacodes> > Join Us on Facebook <http://www.facebook.com/groups/163491717053198/> > > > P Before printing, think about the environment. > > > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to a topic in the > Google Groups "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/excel-macros/zxk2FpH_1LA/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > -- Best Regards, Muneera Sabana -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.