#1
|
|||
|
|||
UTF-8 Creation
Hi
I had a document and need to convert to UTF-8 .csv In a document am having some unnecessay columns & rows that to be deleted first, then create a csv. First 3 rows & First column need to be deleted from a file. [(opened docuemnt type ".docx",".rtf" ,".doc")] First 3 rows are XXXXX name, XXXX number & version ID First column is sequence number. Above rows & column are need to be deleted and then create a csv UTF 8 version with the below format type. SourcePath = InputBox("PLEASE ENTER PATH", "SOURCE PATH") & "" Then delete the unnecessary first 3 rows and first colum. Then create a csv with remaining data as in below format. File Name: Same as the opened document with the extention .csv Save as type: All files "(*.*)" Encoding UTF-8 Saved in the same path (from where we select a file) Can we automate this task by macro... Please help me in this regards & your help is highly appreciated and means a lot to me.... Thanks in advance... For reference PFA. |
#2
|
||||
|
||||
Something along these lines works with your sample doc
Code:
Sub RangeToCSV() Dim aRng As Range, aNewDoc As Document, sPath As String Set aRng = ActiveDocument.Tables(1).Range sPath = ActiveDocument.Path & "\" aRng.Start = ActiveDocument.Tables(1).Rows(4).Range.Start Set aNewDoc = Documents.Add aNewDoc.Range.FormattedText = aRng.FormattedText aNewDoc.Tables(1).Columns(1).Delete aNewDoc.Tables(1).ConvertToText Separator:="," aNewDoc.Paragraphs.Last.Range.Delete aNewDoc.SaveAs2 FileName:=sPath & "Test.csv", FileFormat:=wdFormatUnicodeText MsgBox aNewDoc.FullName, , "File Created" aNewDoc.Close SaveChanges:=False End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Hi,
Its not working, i think we need to add a tab delimiter, please review once... .TextFileTabDelimiter = True & Inser this code... Dim SourcePath As String SourcePath = InputBox("PLEASE ENTER PATH", "SOURCE PATH") & "" Thanks.... |
#4
|
||||
|
||||
Ranjan
The code I produced works perfectly on the sample you posted. You should be able to work out by yourself how to to make the amendments you now require - both are pretty obvious.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Formula Creation | lahanroyal | Excel | 3 | 08-27-2019 11:10 PM |
Document Creation | Caerleon | Word | 1 | 09-11-2015 07:42 PM |
Template creation | Calvinclown | Word | 3 | 09-16-2014 07:19 PM |
Document Creation | Privateer | Word | 3 | 06-20-2013 08:15 PM |
Label Creation | speloquin | Word | 1 | 05-27-2011 03:08 PM |