Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 12-04-2012, 04:13 PM
4mysanity 4mysanity is offline Splitting Out PDFs Windows 7 64bit Splitting Out PDFs Office 2010 64bit
Novice
Splitting Out PDFs
 
Join Date: Nov 2012
Posts: 16
4mysanity is on a distinguished road
Default RE:

Hmm, nope...but Im going to try changing the directory and see if it works there....Ill let you know if this works right away.



Let me ask you this....and you can tell me your thoughts...The first part of the code (the first sub routine) is supposed to split out each paragraph number. The second part of the code (the part you did) - is supposed to insert the images to the pdfs that are going to be created.

Since there are two macro's in two different sub's would it be better if they were combined as one macro?

Do you think that could have any reason why this works, then fails?

Quote:
Originally Posted by macropod View Post
Are you sure you're not trying to save over files you've already created in a previous run of the macro?
Reply With Quote
  #17  
Old 12-04-2012, 04:23 PM
4mysanity 4mysanity is offline Splitting Out PDFs Windows 7 64bit Splitting Out PDFs Office 2010 64bit
Novice
Splitting Out PDFs
 
Join Date: Nov 2012
Posts: 16
4mysanity is on a distinguished road
Default RE:

Hey Macropod,

Alrighty, in response to this, the answer is, I deleted the .pdf's I had previously created with the Macro. I re-ran the Macro, it did what it was supposed to.

So then I went back into the directory, deleted the pdfs once again for a fresh start, then I re-ran the Macro and it started opening blank Word documents again...

Weird and interesting huh?

Quote:
Originally Posted by macropod View Post
Are you sure you're not trying to save over files you've already created in a previous run of the macro?
Reply With Quote
  #18  
Old 12-04-2012, 04:29 PM
macropod's Avatar
macropod macropod is online now Splitting Out PDFs Windows 7 64bit Splitting Out PDFs 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

Did you edit the macro code to point to the correct folder in each case?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #19  
Old 12-04-2012, 04:52 PM
4mysanity 4mysanity is offline Splitting Out PDFs Windows 7 64bit Splitting Out PDFs Office 2010 64bit
Novice
Splitting Out PDFs
 
Join Date: Nov 2012
Posts: 16
4mysanity is on a distinguished road
Default RE:

Yep, I sure did. See the thing is, I can make it work. But when it starts to fail is when - I delete the .pdf's in the directory, then try and execute the Macro a second time.

When executing the Macro a second time, its not that the Macro doesn't work, it just starts to do weird things, like copy the entire word document, to a new Word document and close the original file.

For example, say the original document which has the content is called test.docm, when the Macro is executed a second time it copies all the content from test.docm to a new Word document such as "document 5.docm" then the script wants to delete everything in test.docm and prompts me to save the changes to test.docm

Of course I click, "do not save changes". But Im not sure why its doing this.


Quote:
Originally Posted by macropod View Post
Did you edit the macro code to point to the correct folder in each case?
Reply With Quote
  #20  
Old 12-04-2012, 05:06 PM
4mysanity 4mysanity is offline Splitting Out PDFs Windows 7 64bit Splitting Out PDFs Office 2010 64bit
Novice
Splitting Out PDFs
 
Join Date: Nov 2012
Posts: 16
4mysanity is on a distinguished road
Default RE:

Hey There,

I took some screenshots for you to view as well:

template.jpg example2.JPG document1.jpg

Screenshots:
3007 - template.jpg - this screenshot is of the original document - as you can see the content has been deleted from it.

3008 - example2.jpg - this screenshot is a shot of my task bar, as you can see I have the original document "template.docm" open - but the script has created "Document1.doc"

3009 - Document1.jpg - this is a screenshot of the new document the script is creating, as you can see it has all the content from my original document, template.docm

Just wanted to give some visual aids as to what is happening incase it helps.
Reply With Quote
  #21  
Old 12-04-2012, 05:11 PM
macropod's Avatar
macropod macropod is online now Splitting Out PDFs Windows 7 64bit Splitting Out PDFs 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 4mysanity View Post
The first part of the code (the first sub routine) is supposed to split out each paragraph number. The second part of the code (the part you did) - is supposed to insert the images to the pdfs that are going to be created.

Since there are two macro's in two different sub's would it be better if they were combined as one macro?
Frankly, I'm not sure what your 'Splitter' macro is supposed to achieve that that second macro doesn't already do. The document you've provided has no Section breaks, so there is only ever one Section to process and all that would happen, if anything, is that the document as a whole would be saved as a PDF. That said, the 'Splitter' code could be made much more efficient:
Code:
Sub Splitter()
Dim numlets As Long, Counter As Long, sPath As String, DocName As String
numlets = ActiveDocument.Sections.Count
If numlets > 1 Then numlets = numlets - 1
sPath = "k:\test\images\"
For Counter = 1 To numlets
  DocName = sPath & Format(Counter, "000")
  ActiveDocument.Sections.First.Range.Cut
  Documents.Add
  With ActiveDocument.Range
    .Paste
    .Characters.First = vbNullString
    .SaveAs2 FileName:=DocName, FileFormat:=wdFormatPDF
    .Close
  End With
Next Counter
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #22  
Old 12-04-2012, 05:22 PM
macropod's Avatar
macropod macropod is online now Splitting Out PDFs Windows 7 64bit Splitting Out PDFs 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

Your post #20 suggests you're running your 'Splitter' macro, not the 'InsertPicsToPDF' macro I provided. Your 'Splitter' macro has code for cutting content - which would cut the content out of your 'template' document - my 'InsertPicsToPDF' macro has no code for cutting content.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #23  
Old 12-05-2012, 07:47 AM
4mysanity 4mysanity is offline Splitting Out PDFs Windows 7 64bit Splitting Out PDFs Office 2010 64bit
Novice
Splitting Out PDFs
 
Join Date: Nov 2012
Posts: 16
4mysanity is on a distinguished road
Default RE:

Hey Macropod,

Thanks for the response. You are absolutely right.

I want the paragraph labeled 001 - to have the corresponding image inserted above the paragraph (as the code does) - then I want paragraph 1 split out and saved as 001.pdf

then I want paragraph 2 to have have its corresponding image inserted, then split out and saved as a pdf called 002.

and so...

I think your right, I think Im executing this Macro and on the first go-around it is inserting the images, then splitting out the individual pdfs, as its supposed to.

But then when I delete all the pds that were created, and all the images out of the document to try a second test of the document, only one out of the two Macros are being executed instead of both at the same time.

So does the Macro need to be combined as one instead of two seperate macros?


Quote:
Originally Posted by macropod View Post
Your post #20 suggests you're running your 'Splitter' macro, not the 'InsertPicsToPDF' macro I provided. Your 'Splitter' macro has code for cutting content - which would cut the content out of your 'template' document - my 'InsertPicsToPDF' macro has no code for cutting content.
Reply With Quote
  #24  
Old 12-05-2012, 02:03 PM
macropod's Avatar
macropod macropod is online now Splitting Out PDFs Windows 7 64bit Splitting Out PDFs 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

Why are you bothering with your 'Splitter' macro at all? The 'InsertPicsToPDF' macro I provided makes no use of it for the first round, so why would you expect it to do so for the second?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #25  
Old 12-05-2012, 02:19 PM
4mysanity 4mysanity is offline Splitting Out PDFs Windows 7 64bit Splitting Out PDFs Office 2010 64bit
Novice
Splitting Out PDFs
 
Join Date: Nov 2012
Posts: 16
4mysanity is on a distinguished road
Default RE:

Hey Macropod,

Thanks for the response once again...

To answer your question, that is because the InsertPicstoPDF Macro doesn't split out the paragraph and image and save it as a pdf.

Basically this is the underlying problem Im trying to solve...We get a list of employee descriptions submitted by corporate communications. Those descriptions come in paragraphs, and the paragraphs have labels such as 001, 002, 003, 004, 005, 006 and so on.

In my k:\ directory I provided is where images of all the employees reside. The images of the employees are also numbered 001, 002, 003, 004, 005.

So the macro is supposed to be inserted on the word document we get from communications, and once executed the images are supposed to get inserted above the paragraphs. Once the images are inserted above each paragraph each paragraph and its image have to be saved seperately.

So, image 002 and paragraph 002, will be saved as 002.pdf
Image 003 and paragraph 003, will be saved as 003.pdf

and so on.

So thats why I have the splitter macro in there...Once the images are inserted on the word document its supposed to split out each paragraph.



Quote:
Originally Posted by macropod View Post
Why are you bothering with your 'Splitter' macro at all? The 'InsertPicsToPDF' macro I provided makes no use of it for the first round, so why would you expect it to do so for the second?
Reply With Quote
  #26  
Old 12-05-2012, 02:26 PM
macropod's Avatar
macropod macropod is online now Splitting Out PDFs Windows 7 64bit Splitting Out PDFs 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 4mysanity View Post
To answer your question, that is because the InsertPicstoPDF Macro doesn't split out the paragraph and image and save it as a pdf.
Not so! That's exactly what it does.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #27  
Old 12-05-2012, 02:32 PM
4mysanity 4mysanity is offline Splitting Out PDFs Windows 7 64bit Splitting Out PDFs Office 2010 64bit
Novice
Splitting Out PDFs
 
Join Date: Nov 2012
Posts: 16
4mysanity is on a distinguished road
Default RE:

Look Im not trying to argue my friend, Im just trying to make this work. And again, it does work, its just that if I run it a second time, that's where it starts erroring.

Its not your VBA code, its probably something wrong on my end, like a firewall issue, or something not being cleared...Im not arguing with you sorry if it seemed that way.

The code absolutely does work, my vba editor just starts to error on the second go-around - which Ill have to figure out why thats happening. Although I just noticed....If I stop saving in my k:\ directory and do it on a folder on my desktop. It works perfectly fine ...So Ill just have to do it that way for now.

Thanks for all your help though Macropod! I really appreciate all the effort in trying to help me get through this!...I will mark this topic solved again.

Have a good one.


Quote:
Originally Posted by macropod View Post
Garbage. That's exactly what it does.
Reply With Quote
  #28  
Old 12-05-2012, 03:31 PM
macropod's Avatar
macropod macropod is online now Splitting Out PDFs Windows 7 64bit Splitting Out PDFs 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

Let me put it simply: your 'Splitter' macro contributes nothing to the process. The 'InsertPicsToPDF' macro does all that is required. It both inserts the images and saves them out to a new file.

The problems you are getting are caused solely by running your 'Splitter' macro, not by any firewall or 'other issue'. That macro is predicated on the document it is run on having a separate Section for each numbered paragraph. Your document (or at least the one you attached to post #1 in this thread) is not like that - it has all of them in one section. So, when your 'Splitter' macro tries to cut content on a Section by Section basis, it simply cuts all of the content from the source document and pastes it into the output document.

If you want to be able to generate a new set of pdfs, simply close the source document without saving, then re-open it and re-run the 'InsertPicsToPDF' macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserted PDFs become Pixelated in Powerpoint fongchun PowerPoint 0 11-26-2012 06:24 PM
Splitting Out PDFs My Word 2007 doesnt display PDFs correctly mattk561 Word 8 10-31-2012 08:04 PM
Splitting Out PDFs Embedding PDFs in MS Word 2010 chitownbillj Word 1 06-30-2012 12:01 AM
Creating High Quality PDFs from Word 2010 BrazzellMarketing Word 11 01-27-2012 01:06 PM
Splitting Out PDFs Converting Powerpoint into Fully Accessable PDFs KCD123 PowerPoint 4 09-28-2011 10:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:49 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