codewala

code it

Tool to convert PowerPoint to Word

Was looking for a tool which would easily convert PPT into Word. Found a nice tool to covert the PowerPoint file into Word document.

http://www.okdosoft.com/okdo-ppt-to-word-converter.htm

Features

  • Batch convert numerous Ppt format files once to save your time.
  • Preserve the original layout of your Ppt in an editable Word.
  • Support Convert Ppt to Doc/Docx/Docm by default way.
  • Support save PowerPoint page layout Mode.
  • Support extract the character of PowerPoint to convert.
  • Support convert the lantern slide content to Doc/Docx/Docm by image way.
  • Custom to set the output file name.
  • Custom the Word margin size and page size.
  • You can add the whole folder to convert.
  • Save List: Save the converted files to a list.
  • Load List: Load the saved list files directly to convert.
  • You can set to open the output folder when conversion finished.

April 26, 2011 Posted by | PowerPoint, Word | Leave a comment

macro to select only text from table cell in Word

When I used to copy content from Word from selected table cell into PowerPoint the para formatting used to get lost. To retain the para formatting only the text from the table cell should be copied.

Below is the macro on how to select only the text from a selected table cell.


Sub select_text()
'
Dim oDoc As Document
Dim oRng As Range
'
Set oDoc = ActiveDocument
'
oDoc.Tables(1).Rows(1).Cells(1).Select
'
Set oRng = Selection.Cells(1).Range.Paragraphs(1).Range
oRng.End = oRng.Cells(1).Range.End - 1
oRng.Select
'
End Sub

April 11, 2011 Posted by | VBA, Word | Leave a comment

Macro to convert String into Array


'----------------------------------
Option Explicit
'
Sub ConvertStringToArray()
'
Dim media_str As String
Dim media() As String
Dim mediaLen As Long
Dim m As Long
'
media_str = "abc.wav , xyz.wmv , efg.jpg"
media() = Split(media_str, ",")
mediaLen = UBound(media)
'
For m = 0 To mediaLen
MsgBox media(m)
Next m
'
End Sub
'----------------------------------

January 6, 2011 Posted by | VBA, Word | Leave a comment

Macro to import notes from PowerPoint into Word

I needed to export only the notes from PowerPoint into Word. In PowerPoint 2003, we can use “File – send to – MS Office Word” to export the PowerPoint as Word. But faced two issues with this
1. There is no option to only export notes section
2. The bullet formatting of the notes section is lost at the time of export. This issue has been resloved in MS Office 2007.

Wrote my own macro in Word which will only import the notes section from PowerPoint into Word and also retain the bullet formatting given in PowerPoint.


'-------------------------------------------------------------
Option Explicit
'
Sub ImportNotes()

' FOR WORD
Dim oDoc As Document
Dim docPath As String
Dim oTable As Table
Dim oRow As Row
' FOR POWERPOINT
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppFileName As String
Dim ppFilePath As String
Dim oSlides As Slides
Dim oSlide As Slide
Dim oShape As Shape
'
Set oDoc = ActiveDocument
Set oTable = oDoc.Tables(1)
docPath = oDoc.Path
'
ppFileName = "notes.ppt"
ppFilePath = docPath & "\" & ppFileName
'
Set ppApp = CreateObject("PowerPoint.Application")
'
ppApp.Visible = True
ppApp.Activate
'
Set ppPres = ppApp.Presentations.Open(ppFilePath)
Set oSlides = ppPres.Slides
'
For Each oSlide In oSlides
'
oTable.Rows.Add
Set oRow = oTable.Rows(oTable.Rows.Count)
oSlide.NotesPage.Shapes(2).TextFrame.TextRange.Copy
oRow.Cells(1).Range.Text = "slide " & oSlide.SlideIndex
oRow.Cells(2).Range.PasteSpecial ppPasteRTF
'
Next oSlide
'
End Sub
'-------------------------------------------------------------

January 5, 2011 Posted by | PowerPoint, VBA, Word | 5 Comments

Macro to import colored JPEG image as greyscale into Word

Following is the vba code to import JPEG image into word and then covert it into greyscale


'----------------------------------------------------------------------
Option Explicit
'
Sub ImportImageIntoWord()
'
Dim oDoc As Document
Dim docPath As String
Dim imgName As String
Dim imgPath As String
Dim wdInlineImage As InlineShape
'
Set oDoc = ActiveDocument
docPath = oDoc.path
'
imgName = "sunset.jpg"
imgPath = docPath & "\" & imgName
'
Set wdInlineImage = Selection.InlineShapes.AddPicture(imgPath, False, True)

wdInlineImage.ScaleWidth = 50
wdInlineImage.ScaleHeight = 50
'
wdInlineImage.PictureFormat.ColorType = msoPictureGrayscale
'
End Sub
'----------------------------------------------------------------------

January 4, 2011 Posted by | VBA, Word | Leave a comment

Macro to retain paragraph formatting when text is copied from Word to PowerPoint

In my earlier post I had mentioned about paragraph formatting is lost when text is copied from Word to PowerPoint.

Wrote a macro in PowerPoint to retain the paragraph formatting of the copied text from Word to PowerPoint.


'--------------------------------------------------
Option Explicit
'
'
'
Sub CopyTextFromWordWithParaFormat()
'
' FOR WORD
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdFile As String
Dim oTable As Word.Table
Dim oRow As Word.Row
Dim oParas As Word.Paragraphs
Dim oPara As Word.Paragraph
Dim paraBullet()
Dim paraIndentLevel()
Dim p As Long
Dim wdParaCount As Long
Dim counter As Long
'
' FOR POWERPOINT
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim oSlide As Slide
Dim oShape As PowerPoint.Shape
Dim ppParaCount As Long
Dim path As String
'
' INITILIZE
Set ppApp = PowerPoint.Application
Set ppPres = ActivePresentation
path = ppPres.path
p = 1
counter = 1
wdParaCount = 0
ppParaCount = 0
'
'
'-----------------------------------------------------
' SWITCH TO WORD TO READ THE CONTENT
'-----------------------------------------------------
Set wdApp = CreateObject("Word.Application")
wdFile = path & "/" & "sample.doc"
'
Set wdDoc = wdApp.Documents.Open(wdFile)
wdApp.Visible = True
wdDoc.Activate
'
'
' READ WORD TABLE
Set oTable = wdDoc.Tables(1)
Set oRow = oTable.Rows(1)
Set oParas = oRow.Cells(1).Range.Paragraphs
'
wdParaCount = oParas.Count
'
' GET PARAFORMATTING OF EACH PARAGRAPH
ReDim paraBullet(wdParaCount)
ReDim paraIndentLevel(wdParaCount)
'
For p = 1 To wdParaCount
'
Set oPara = oParas(p)
'
' ONLY INCLUDE THOSE PARA'S WHICH ARE NOT EMPTY
If (Len(oPara.Range.Text) > 1) Then
paraBullet(counter) = oPara.Range.ListFormat.ListType
paraIndentLevel(counter) = oPara.Range.ListFormat.ListLevelNumber
counter = counter + 1
End If
'
Next p
'
'
' COPY THE TEXT FROM WORD
oRow.Cells(1).Select
SendKeys "^c", 1
'
'
'---------------------------------------------------------
' SWITCH TO POWERPOINT TO PASTE AND FORMAT THE COPIED TEXT
'---------------------------------------------------------
'
ppApp.Activate
'
With ActivePresentation
'
Set oSlide = .Slides(1)
Set oShape = oSlide.Shapes("Rectangle 3")
'
' PASTE THE TEXT COPIED FROM WORD INTO THE SHAPE
oShape.TextFrame.TextRange.Text = ""
oShape.TextFrame.TextRange.Characters(1, 0).Select
SendKeys "^v", 1
ppParaCount = oShape.TextFrame.TextRange.Paragraphs.Count
'
'
' FIRST CLEAR THE PARAGRAPH FORMATTING FROM POWERPOINT
oShape.TextFrame.TextRange.Paragraphs(1, ppParaCount).ParagraphFormat.Bullet.Type = ppBulletNone
oShape.TextFrame.TextRange.Paragraphs(1, ppParaCount).IndentLevel = 0
'
' APPLY THE WORD PARAGRAPH FORMATTING INTO POWERPOINT
For p = 1 To ppParaCount
'
If (paraBullet(p) = 2 Or paraBullet(p) = 3) Then ' 2 for bullet and 3 for numbered bullet
oShape.TextFrame.TextRange.Paragraphs(p).ParagraphFormat.Bullet.Visible = msoTrue
oShape.TextFrame.TextRange.Paragraphs(p).IndentLevel = paraIndentLevel(p) + 1
End If
'
Next p
'
End With
'
' EXIT WORD
wdDoc.Close
wdApp.Quit
'
' CLEAR ARRAY
ReDim paraBullet(0)
ReDim paraIndentLevel(0)
'
' CLEAR OBJECTS
Set oShape = Nothing
Set oSlide = Nothing
Set oPara = Nothing
Set oRow = Nothing
Set oTable = Nothing
Set wdDoc = Nothing
Set wdApp = Nothing
'
MsgBox "process complete."
'
End Sub

‘————————————————–

December 29, 2010 Posted by | PowerPoint, VBA, Word | Leave a comment

Add table number to each table from # table onwards in Word

I had a word document with many tables. The task was to add an ID (#) in the first row of the table. The insersion of the ID needed to start from certain Table onwards. Came up with a macro which when executed – will popup an input box – type the table number from where the ID needs to be inserted from and click ok.


'--------------------------------------------
Option Explicit
'
Sub AddTableID()
'
Dim tableIndex As String
Dim oDoc As Document
Dim oTables As Tables
Dim oTable As Table
Dim oRow As Row
Dim totalTables As Long
Dim t As Long
Dim tableID As Long
'
tableID = 1
tableIndex = InputBox(Prompt:="Add Table ID from which Table onwards", Title:="", Default:="")
If tableIndex = vbNullString Then
' dont do anything
Else
'
Set oDoc = ActiveDocument
Set oTables = oDoc.Tables
totalTables = oTables.Count
'
For t = tableIndex To totalTables
Set oTable = oTables(t)
'oTable.Rows.Add BeforeRow:=oTable.Rows(1)
Set oRow = oTable.Rows(1)
oRow.Cells(1).Range.Text = "Table ID : " & tableID
tableID = tableID + 1
Next t
'
Set oRow = Nothing
Set oTable = Nothing
Set oTables = Nothing
Set oDoc = Nothing
'
End If
'
End Sub
'--------------------------------------------

add table id

December 26, 2010 Posted by | VBA, Word | Leave a comment

Workaround to retain the paragraph formatting of text when copied from Word to Powerpoint

While developing an automation program which will copy text from Word file into PowerPoint, came across this issue of PowerPoint not able to retain the paragraph formatting of the text. This happens when the text has mix of bulleted and non-bulleted paragraphs. It seems that PowerPoint can only retain the formatting if each paragraph in Word is bulleted. Refer the screenshots to see the issue and the workaround.

Formatted paragraph text in word

When Copied into PowerPoint

Modified paragraph text in word

When Copied into PowerPoint

December 25, 2010 Posted by | PowerPoint, Word | 1 Comment

Macro to delete empty rows from a table in word


Sub DeleteEmptyRowsFromTable()
'
Dim oDoc As Document
Dim oTable As Table
Dim oRow As Row
Dim totalRows As Long
Dim textInCell As String
Dim i As Long
'
Set oDoc = ActiveDocument
Set oTable = oDoc.Tables(1)
'
totalRows = oTable.Rows.Count
'
For i = totalRows To 1 Step -1
Set oRow = oTable.Rows(i)
textInCell = CleanText(oRow.Cells(1).Range.Text)
'
If textInCell = "" Then
oRow.Delete
End If
Next i
'
End Sub
'
'
'
Function CleanText(pm_str As String) As String
'
pm_str = Trim(pm_str)
pm_str = Replace$(pm_str, "", "")
pm_str = Replace$(pm_str, Chr(13), "") ' vbCrLf (return)
pm_str = Replace$(pm_str, Chr(7), "") ' vbCrLf (return)
CleanText = pm_str
'
End Function

December 24, 2010 Posted by | VBA, Word | Leave a comment