Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-27-2021, 12:48 PM
ranjan ranjan is offline UTF-8 Creation Windows 10 UTF-8 Creation Office 2019
Advanced Beginner
UTF-8 Creation
 
Join Date: May 2021
Posts: 76
ranjan is on a distinguished road
Default 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.
Attached Files
File Type: zip Test.zip (50.1 KB, 5 views)
Reply With Quote
  #2  
Old 08-27-2021, 05:03 PM
Guessed's Avatar
Guessed Guessed is offline UTF-8 Creation Windows 10 UTF-8 Creation Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #3  
Old 08-27-2021, 10:24 PM
ranjan ranjan is offline UTF-8 Creation Windows 10 UTF-8 Creation Office 2019
Advanced Beginner
UTF-8 Creation
 
Join Date: May 2021
Posts: 76
ranjan is on a distinguished road
Default

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....
Reply With Quote
  #4  
Old 08-28-2021, 05:27 PM
Guessed's Avatar
Guessed Guessed is offline UTF-8 Creation Windows 10 UTF-8 Creation Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula Creation lahanroyal Excel 3 08-27-2019 11:10 PM
UTF-8 Creation Document Creation Caerleon Word 1 09-11-2015 07:42 PM
UTF-8 Creation Template creation Calvinclown Word 3 09-16-2014 07:19 PM
UTF-8 Creation Document Creation Privateer Word 3 06-20-2013 08:15 PM
UTF-8 Creation Label Creation speloquin Word 1 05-27-2011 03:08 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft