Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-24-2014, 03:44 PM
ekesawi ekesawi is offline Convert indent to tabs a document converted from PDF Windows 7 64bit Convert indent to tabs a document converted from PDF Office 2010 64bit
Novice
Convert indent to tabs a document converted from PDF
 
Join Date: Dec 2012
Posts: 9
ekesawi is on a distinguished road
Default Convert indent to tabs a document converted from PDF

Ho All—



I ran into a problem that I just could find anything that helps. I converted a PDF file to an MS Word file via Adobe Pro. The document contains various different length indents. When I aligned the text to the right, all indents disappeared.

The problem: I want to change the various indents on the Word document to spaces or tabs, so that when I align all text, the indented part will remain indented. Is there a way, particularly for a large document, to change all indents to tabs or spaces?

Thanks you in advance, EK
Reply With Quote
  #2  
Old 02-24-2014, 04:40 PM
Charles Kenyon Charles Kenyon is offline Convert indent to tabs a document converted from PDF Windows 7 64bit Convert indent to tabs a document converted from PDF Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

There is no Automatic way. You could try AutoFormat on a copy of your converted document. First set your AutoFormat options under AutoCorrect Options on the Proofing options. Then Alt+Ctrl+K in the document starts AutoFormat.

Generally I do not work with converted documents. I import the text into a clean Word document as plain text and reformat it using Styles. The conversion processes used by any software I've used, including those by Word, give very messy documents when you try to edit them. In addition, I suspect that some of those Indents are margin changes (section breaks).
Reply With Quote
  #3  
Old 02-24-2014, 05:27 PM
macropod's Avatar
macropod macropod is offline Convert indent to tabs a document converted from PDF Windows 7 32bit Convert indent to tabs a document converted from PDF Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by ekesawi View Post
I want to change the various indents on the Word document to spaces or tabs, so that when I align all text, the indented part will remain indented. Is there a way, particularly for a large document, to change all indents to tabs or spaces?
That is a really bad approach! Inserting spaces and/or tabs to mimic indents makes any document a nightmare to maintain. What's wrong with using separate, indented, paragraphs (based on a properly-defined paragraph Style) where you need them?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 02-24-2014, 07:31 PM
ekesawi ekesawi is offline Convert indent to tabs a document converted from PDF Windows 7 64bit Convert indent to tabs a document converted from PDF Office 2010 64bit
Novice
Convert indent to tabs a document converted from PDF
 
Join Date: Dec 2012
Posts: 9
ekesawi is on a distinguished road
Default

Thank you for the input. The reason I want to convert indents to tabs or spaces is that I downloaded a PDF copy (more than 1000 pages) of a book I bought. The book is a computer programming book. I want to convert the PDF to an MS Word because then I can copy the code parts and paste them on my editor so I can run them without having to indent them manually and indenting is important for this language.
Here is an example. The general text, the first 2 lines and the last one, and the indented code in between. I want if possible to select-or any other way- all the code parts and replace indents with tab or spaces.

…..only when the file is run as a top-level script, not when it is imported (this new version of the module file is renamed minmax2.py here):
print(‘I am:’, name)
def minmax(test, *args):
res = args[0]
for arg in args[1:]:
if test(arg, res):
res = arg return res
We’re also printing the value of nameat the top here to trace its value. Python creates and…….

PS..i hope the indents are visible when posted
Reply With Quote
  #5  
Old 02-24-2014, 07:36 PM
ekesawi ekesawi is offline Convert indent to tabs a document converted from PDF Windows 7 64bit Convert indent to tabs a document converted from PDF Office 2010 64bit
Novice
Convert indent to tabs a document converted from PDF
 
Join Date: Dec 2012
Posts: 9
ekesawi is on a distinguished road
Default

Please note that the on my previous post, the first 2 lines and the last one are not indented but the ones in between are with variable indent length. Thanks. EK
Reply With Quote
  #6  
Old 02-24-2014, 07:43 PM
macropod's Avatar
macropod macropod is offline Convert indent to tabs a document converted from PDF Windows 7 32bit Convert indent to tabs a document converted from PDF Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The indents didn't survive (you'd need to enclose the code in the board's Code tags for that - they're on the 'Go Advanced' tab).

That said, I am aware that code indenters are available for a range of platforms, so that may be a better solution than trying to do it from within Word. Conversely, I've written macros before for (IIRC) going the other way, so it shouldn't be too difficult to reverse the process.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 02-24-2014, 09:44 PM
macropod's Avatar
macropod macropod is offline Convert indent to tabs a document converted from PDF Windows 7 32bit Convert indent to tabs a document converted from PDF Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try something along the following lines:
Code:
Sub Demo()
Application.ScreenUpdating = True
Dim i As Long
With Selection
  For i = 1 To .Paragraphs.Count
    With .Paragraphs(i).Range.Characters.First
      Select Case Int(PointsToInches(.Information(wdHorizontalPositionRelativeToTextBoundary)) * 4)
        Case 1: .InsertBefore vbTab
        Case 2: .InsertBefore vbTab & vbTab
        Case 3: .InsertBefore vbTab & vbTab & vbTab
        Case 4: .InsertBefore vbTab & vbTab & vbTab & vbTab
        Case 5: .InsertBefore vbTab & vbTab & vbTab & vbTab & vbTab
        Case 6: .InsertBefore vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
        Case 7: .InsertBefore vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
        Case 8: .InsertBefore vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
        Case 9: .InsertBefore vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
      End Select
    End With
  Next
  .ParagraphFormat.Alignment = wdAlignParagraphLeft
  .ClearParagraphAllFormatting
End With
Application.ScreenUpdating = True
End Sub
or:
Code:
Sub Demo()
Application.ScreenUpdating = True
Dim i As Long, j As Long, StrTmp As String
With Selection
  For i = 1 To .Paragraphs.Count
    StrTmp = vbNullString
    With .Paragraphs(i).Range.Characters.First
      For j = 0 To Int(PointsToInches(.Information(wdHorizontalPositionRelativeToTextBoundary)) * 4)
        StrTmp = StrTmp & vbTab
      Next
      .InsertBefore StrTmp
    End With
  Next
  .ParagraphFormat.Alignment = wdAlignParagraphLeft
  .ClearParagraphAllFormatting
End With
Application.ScreenUpdating = True
End Sub
As coded, the macros apply tabs to a selected block of text. You may need to play around with the '* 4' and even subtract a constant value from than line to get the kind of indenting you desire. I'd suggest going even further: Define a 'code' Style with whatever final tab-stop positions you'd prefer and apply that to the range after the '.ClearParagraphAllFormatting' line. The second macro is more flexible, as it accommodates any level of indenting.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 02-24-2014 at 09:49 PM. Reason: Alternative macro
Reply With Quote
  #8  
Old 02-25-2014, 12:09 AM
eNGiNe eNGiNe is offline Convert indent to tabs a document converted from PDF Windows 7 32bit Convert indent to tabs a document converted from PDF Office 2010 64bit
Expert
 
Join Date: Jan 2012
Location: Brussels [BE]
Posts: 746
eNGiNe is on a distinguished road
Default

Quote:
Originally Posted by ekesawi View Post
The document contains various different length indents. When I aligned the text to the right, all indents disappeared.
But that sounds about what I'd expect: if the indents are from the left margin and you then right-align the text, aren't you going to end up with a ragged left margin determined solely by the length of each line?

Quote:
Originally Posted by ekesawi View Post
I want to convert the PDF to an MS Word because then I can copy the code parts and paste them on my editor

If I wanted to copy/paste a code example from a .pdf into an editor I wouldn't use Word (or anything else) as an intermediate program. Might it not save time in the long run to copy/paste each code example as you need it, rather than try to process the whole book all at once? you can always save each code snippet in a reference file outside the code …
Reply With Quote
  #9  
Old 02-25-2014, 12:40 AM
macropod's Avatar
macropod macropod is offline Convert indent to tabs a document converted from PDF Windows 7 32bit Convert indent to tabs a document converted from PDF Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by eNGiNe View Post
If I wanted to copy/paste a code example from a .pdf into an editor I wouldn't use Word (or anything else) as an intermediate program.
That's all very well if copying & pasting into an IDE preserves the indents, but few do - they generally rely on spaces/tabs to provide that, not paragraph indents.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 02-25-2014, 04:20 PM
ekesawi ekesawi is offline Convert indent to tabs a document converted from PDF Windows 7 64bit Convert indent to tabs a document converted from PDF Office 2010 64bit
Novice
Convert indent to tabs a document converted from PDF
 
Join Date: Dec 2012
Posts: 9
ekesawi is on a distinguished road
Default

Thank Paul and other for the great input and the code for the macros- a great help. Obviously there are other ways that might be even more efficient to accomplish what I had asked for, but for now, this works out well for me; that’s copying code directly from a Word document to IDLE.
I tried the 1st macro and it works very well. After running the macro, all I had to do is to replace tabs with the default number of space in IDEL

Thank you all again and best of luck.

EK Esawi
Reply With Quote
  #11  
Old 02-25-2014, 04:49 PM
macropod's Avatar
macropod macropod is offline Convert indent to tabs a document converted from PDF Windows 7 32bit Convert indent to tabs a document converted from PDF Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by ekesawi View Post
After running the macro, all I had to do is to replace tabs with the default number of space in IDEL
You could eliminate that step by changing every occurrence of vbTab with "__" (i.e a pair of double quotes with two spaces [or a different number of spaces] between them). For the first macro, you could even concatenate the vbTab, vbTab & vbTab etc. sets into single strings of "__", "____" and so on.

PS: I've inserted '_' characters because the board software deletes repeated spaces.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 02-25-2014, 08:36 PM
ekesawi ekesawi is offline Convert indent to tabs a document converted from PDF Windows 7 64bit Convert indent to tabs a document converted from PDF Office 2010 64bit
Novice
Convert indent to tabs a document converted from PDF
 
Join Date: Dec 2012
Posts: 9
ekesawi is on a distinguished road
Default

Thanks again Paul and others. I am finding out how hard and how much work is needed to get the 1500 page book converted to MS Word, and converting it accurately. I thought I can divide it into several parts and once I made the changes in one, I can record a macro and run it for the others. But I am already discouraged and not sure if it’s worth it.
I am about to give up on the converting idea. Instead I will indent manually short code; for longer code I will convert it to Word and run the macro you posted to preserve the indenting and go from there.
Thanks again. EK Esawi
Reply With Quote
  #13  
Old 02-25-2014, 09:47 PM
fumei fumei is offline Convert indent to tabs a document converted from PDF Windows 7 64bit Convert indent to tabs a document converted from PDF Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Quote:
I am finding out how hard and how much work is needed to get the 1500 page book converted to MS Word, and converting it accurately.
This is what Charles was getting at. It is bad (hard) enough for small documents. I can not imagine what a nightmare a 1500 page document would be.
Reply With Quote
  #14  
Old 02-26-2014, 01:47 PM
ekesawi ekesawi is offline Convert indent to tabs a document converted from PDF Windows 7 64bit Convert indent to tabs a document converted from PDF Office 2010 64bit
Novice
Convert indent to tabs a document converted from PDF
 
Join Date: Dec 2012
Posts: 9
ekesawi is on a distinguished road
Default

Hi Again,

I hope this question is not out of place here. I have Adobe Acrobat Pro Version 10. Is there a way to change the margins and font for the whole document? I could only change the font size one page at a time and could not find how, if all possible, to change the margins. When I changed the font w/o changing the margins, part of the text is invisible.

Thanks again.

EK Esawi
Reply With Quote
  #15  
Old 02-26-2014, 02:53 PM
macropod's Avatar
macropod macropod is offline Convert indent to tabs a document converted from PDF Windows 7 32bit Convert indent to tabs a document converted from PDF Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It's not clear from your post whether you want to make the change in Adobe Acrobat Pro or in Word. In Word, press Ctrl-A selects the entire document, so you can make global changes. It would probably be unwise to change all the indents that way, though.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert indent to tabs a document converted from PDF Convert word document to pdf Catty Word VBA 1 12-11-2013 03:57 PM
Words in my document were converted to numbers???? MikeD23 Word 1 08-26-2012 11:09 AM
Can you see how much time I worked on Word 2007/2010 document when converted to PDF? Papa Bear Word 1 08-14-2012 05:14 AM
My plain text post got converted to rich text in a reply, how to convert it back? david.karr Outlook 0 01-05-2012 09:46 AM
Convert indent to tabs a document converted from PDF PDF to Word(.doc) document not convert correctly gonner Word 1 09-10-2011 03:25 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:40 PM.


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