Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

Template will not print second page

 
Post new topic   Reply to topic    Computer Forum Forum Index -> word vba customization
View previous topic :: View next topic  
Author Message
server
Guest





PostPosted: Mon Apr 23, 2007 9:49 pm    Post subject: Template will not print second page Reply with quote

message unavailable
Back to top
Google
Sponsor





PostPosted: Mon Apr 23, 2007 9:49 pm    Post subject: Advertisement

Back to top
Cameron
Guest





PostPosted: Mon Apr 23, 2007 9:50 pm    Post subject: Re: Template will not print second page Reply with quote

Well, what happens with this document is there are a number of paged in it.
The button is placed in the header of each document and if the user wants ot
print out that particular page then certain attached pages also print out
(hense the extra printout statement). But there is one instance in the list
of pages where the context stems over to a second page. For the most part the
current page method works fine but just this one instance. Is there a way to
have the Button click event be able to check to see if there are two or more
pages? Could I out some sort of reference in the document that could trigger
that there where more then two pages and then have to printout method change
to accomidate more then one page? I ask because there is a template file that
could very well have the same problem.

"Doug Robbins - Word MVP" wrote:

Quote:
I am not sure why you have two

Application.PrintOut

routines, but your problem is almost certainly cause by the following in the
first one

Range:=wdPrintCurrentPage, _

as it will cause only the current page to be printed. That is one page
only.

As you are not setting any of the other parameters of the PrintOut command,
all that you probably should be using is:

ActiveDocument.PrintOut

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Cameron" <Cameron@discussions.microsoft.com> wrote in message
news:054EA400-7E02-4AFF-9278-528E1FE8D148@microsoft.com...
Private Sub CommandButton1_Click()
Application.PrintOut FileName:="", _
Range:=wdPrintCurrentPage, _
Item:=wdPrintDocumentContent, _
Copies:=1, _
Pages:="", _
PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, _
Collate:=True, _
Background:=True, _
PrintToFile:=False, _
PrintZoomColumn:=0, _
PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0

Application.PrintOut FileName:="", _
Range:=wdPrintRangeOfPages, _
Item:=wdPrintDocumentContent, _
Copies:=1, _
Pages:="2-3", _
PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, _
Collate:=True, _
Background:=True, _
PrintToFile:=False, _
PrintZoomColumn:=0, _
PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0

This is what I have, but when the first page prints out it is often more
then 1 page in lenght, is there a way to set the macro up to print out one
page if it has one page and two or more if it has more?

I'm not all that familur with scripting inside word.

"Doug Robbins - Word MVP" wrote:

Show us the code that you presently have behind the button.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Cameron" <Cameron@discussions.microsoft.com> wrote in message
news:22E60743-6D25-4B3A-AA3B-7AF2F8532D04@microsoft.com...
I have a template file that has a button on the form that prints out
attached
files but in some instances will not print out the second page of the
primary
document. How do you program the print button to print the first and
second
page of the template and then the attachement pages also?





Back to top
Alan B. Densky
Guest





PostPosted: Mon Apr 23, 2007 10:17 pm    Post subject: Re: Macro help needed please Reply with quote

Hi Jay,

Thanks for your help. This is pretty close. I just need to know what I can
replace the .Execute Replace:=wdReplaceAll
with so that it doesn't delete every instance in the document, just the
first one it comes to. I tried wdReplace, but it didn't like that.

Alan


"Jay Freedman" <jay.freedman@verizon.net> wrote in message
news:vdkl23dahr2nkafc8e4c49c22lk5sd9l98@4ax.com...
Quote:
Hi Alan,

I already gave you the macro code. You just have to put in the actual
markers for the start and end of the block, instead of the "StartText"
and "StopText" that I inserted as placeholders.

If that isn't what you want, please let me know what part of its
behavior should be changed.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 21 Apr 2007 20:52:22 -0400, "Alan B. Densky"
sales@neuro-vision.us> wrote:

Hi Jay,

Thanks for your help. I do need to do it in a macro. I'll tell you
exactly
what I'm doing, and then you'll understand.

I write articles that I submit to article directories to market my
website.
The submission rules for every article directory are different, but they
basically fall into two groups:

1. Directories that allow you to have links in your article's body
2. Directories that DO NOT allow you to have links in your article's body

I write the article without links, and then write a block of text (a
couple
of paragraphs) that does have links. I mark the start and the end of the
block that doesn't have links, and I mark the start and the end of the
block
that does have links.

My articles are spun, that is - each article is setup into a seed article
format that has hundreds of synonomous words and phrases. The article
spinning software spins out hundreds of variations of the article into
one
long document. Each version of the article is a minimum of 30% different
from every other version. No mind you, they all say the same thing, but
they
use different words.

Since each version of the article is different, each block (either with
or
without the links) varies in length. So I need to be able to search for
the
beginning and the ending of each block that is to be deleted. Merely
counting lines with a down arrow is not nearly accurate enough.

This allows me to submit a different and unique version of each article
to
every article directory. This is to escape the Google duplicate content
filters.

Now, as I visit each article directory, I advance to the next version of
the
article in the document, and I run the appropriate macro which finds
either
the block of text that has links, or the block of text that doesn't have
links, and it deletes the appropriate block to prep the article based on
the
requirements of the specific article directory.

This happens hundreds of times. Manually finding and deleting each of
these
blocks of text is tedius and very time consuming.

So hopefully now that you understand why I need to be able to find
certain
blocks and select them for deletion, you will give me the info that I
requested.

As far as using the find dialog, or using it and recording it in a macro,
I've been doing that for many, many years.

Thanks,
Alan





"Jay Freedman" <jay.freedman@verizon.net> wrote in message
news:l4ui231s1e7fjvqvtptahaett8ehg2q4ji@4ax.com...
A macro isn't really necessary, unless you need to do the same thing
repeatedly. All you need is a wildcard replace. The theory and
background are at http://www.gmayor.com/replace_using_wildcards.htm.

Since you didn't reveal the magic text of the start and stop markers,
I'll simulate them with "StartText" and "StopText".

- Open the Replace dialog, click the More button, and check the "Use
wildcards" box.

- In the Find What box, enter

(StartText)(*)(StopText)

- In the Replace With box, if you want to keep the StartText and
StopText markers, enter the code

\1\3

If you want the whole thing to disappear including the markers, leave
the Replace With box empty.

- Click the Replace All button.

As a macro, the procedure should be coded like this:

Sub demo()
Dim oRg As Range
Set oRg = ActiveDocument.Range
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(StartText)(*)(StopText)"
.Replacement.Text = "\1\3"
.Format = False
.MatchWildcards = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Fri, 20 Apr 2007 15:33:13 -0400, "Alan B. Densky"
sales@neuro-vision.us> wrote:

Hello,

I'm using Word 2000.

I am trying to write a macro that will delete a specifi parts of a
document.

A static text string that never changes is in the document and it
marks
the
BEGINNING of the block that I want to select and delete.

A static text string that never changes is in the document and it
marks
the
END of the block that I want to select and delete.

The amount of text between the starting point and the ending point
(that
I
want to delete) varies with each document.

I need to be able to somehow use the Edit | Find to find that ending
string
and then select all of the text between the starting point and the
ending
point.

Does anyone know how to do this? If so, could you please write a macro
and
post it? I'm sure that I could take your code and insert it into the
macro
editor and make the other changes that I need.

Thank you,

Alan

Back to top
Alan B. Densky
Guest





PostPosted: Tue Apr 24, 2007 5:26 am    Post subject: Re: Macro help needed please Reply with quote

Hi Jay,

Forget the previous post. I've just about got everything working now. I
have one section of the macro left to do.

After I do the find & replace, I need to select a range of text. I have to
go back up to the top of the article (this is not the top of the document
because there is a string of hundreds of versions of the article in this
very long document.

Then I need to select a range of text (moving down in the document).

It would also be nice if I could copy that range to the clipboard.

Here is what I have so far:
Sub LeaveLinks()
'
' LeaveLinks Macro
' Macro recorded 4/18/2007
'
'Find the string that starts the links block of text and delete the text on
that line
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "LINKS SECTION======"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With

'Delete the block of text that doesn't have any links in it
Dim oRg As Range
Set oRg = ActiveDocument.Range
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(NO LINKS SECTION======)(*)(END NO LINKS SECTION======)"
.Replacement.Text = ""
.Forward = True
.Format = False
.MatchWildcards = True
.Wrap = wdFindContinue
.Execute Replace:=Word.WdReplace.wdReplaceOne
End With

'Go back up and find the beginning of the article

Selection.Find.ClearFormatting
With Selection.Find
.Text = "Article With Back links"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute

'Select the range of text to copy to the clipboard
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(Article With Back links)(*)(END NO LINKS SECTION======2)"
' ' .Replacement.Text = ""
.Forward = True
.Format = False
.MatchWildcards = True
.Wrap = wdFindContinue
.Execute Replace:=Word.WdReplace.wdReplaceOne
End With

'Copy the selected range to the clipboard

End Sub



Thanks for all of your help!

Alan


"Alan B. Densky" <sales@neuro-vision.us> wrote in message
news:MeaXh.33790$254.17869@bignews7.bellsouth.net...
Quote:
Hi Jay,

Thanks for your help. This is pretty close. I just need to know what I can
replace the .Execute Replace:=wdReplaceAll
with so that it doesn't delete every instance in the document, just the
first one it comes to. I tried wdReplace, but it didn't like that.

Alan


"Jay Freedman" <jay.freedman@verizon.net> wrote in message
news:vdkl23dahr2nkafc8e4c49c22lk5sd9l98@4ax.com...
Hi Alan,

I already gave you the macro code. You just have to put in the actual
markers for the start and end of the block, instead of the "StartText"
and "StopText" that I inserted as placeholders.

If that isn't what you want, please let me know what part of its
behavior should be changed.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 21 Apr 2007 20:52:22 -0400, "Alan B. Densky"
sales@neuro-vision.us> wrote:

Hi Jay,

Thanks for your help. I do need to do it in a macro. I'll tell you
exactly
what I'm doing, and then you'll understand.

I write articles that I submit to article directories to market my
website.
The submission rules for every article directory are different, but they
basically fall into two groups:

1. Directories that allow you to have links in your article's body
2. Directories that DO NOT allow you to have links in your article's
body

I write the article without links, and then write a block of text (a
couple
of paragraphs) that does have links. I mark the start and the end of the
block that doesn't have links, and I mark the start and the end of the
block
that does have links.

My articles are spun, that is - each article is setup into a seed
article
format that has hundreds of synonomous words and phrases. The article
spinning software spins out hundreds of variations of the article into
one
long document. Each version of the article is a minimum of 30% different
from every other version. No mind you, they all say the same thing, but
they
use different words.

Since each version of the article is different, each block (either with
or
without the links) varies in length. So I need to be able to search for
the
beginning and the ending of each block that is to be deleted. Merely
counting lines with a down arrow is not nearly accurate enough.

This allows me to submit a different and unique version of each article
to
every article directory. This is to escape the Google duplicate content
filters.

Now, as I visit each article directory, I advance to the next version of
the
article in the document, and I run the appropriate macro which finds
either
the block of text that has links, or the block of text that doesn't have
links, and it deletes the appropriate block to prep the article based on
the
requirements of the specific article directory.

This happens hundreds of times. Manually finding and deleting each of
these
blocks of text is tedius and very time consuming.

So hopefully now that you understand why I need to be able to find
certain
blocks and select them for deletion, you will give me the info that I
requested.

As far as using the find dialog, or using it and recording it in a
macro,
I've been doing that for many, many years.

Thanks,
Alan





"Jay Freedman" <jay.freedman@verizon.net> wrote in message
news:l4ui231s1e7fjvqvtptahaett8ehg2q4ji@4ax.com...
A macro isn't really necessary, unless you need to do the same thing
repeatedly. All you need is a wildcard replace. The theory and
background are at http://www.gmayor.com/replace_using_wildcards.htm.

Since you didn't reveal the magic text of the start and stop markers,
I'll simulate them with "StartText" and "StopText".

- Open the Replace dialog, click the More button, and check the "Use
wildcards" box.

- In the Find What box, enter

(StartText)(*)(StopText)

- In the Replace With box, if you want to keep the StartText and
StopText markers, enter the code

\1\3

If you want the whole thing to disappear including the markers, leave
the Replace With box empty.

- Click the Replace All button.

As a macro, the procedure should be coded like this:

Sub demo()
Dim oRg As Range
Set oRg = ActiveDocument.Range
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(StartText)(*)(StopText)"
.Replacement.Text = "\1\3"
.Format = False
.MatchWildcards = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Fri, 20 Apr 2007 15:33:13 -0400, "Alan B. Densky"
sales@neuro-vision.us> wrote:

Hello,

I'm using Word 2000.

I am trying to write a macro that will delete a specifi parts of a
document.

A static text string that never changes is in the document and it
marks
the
BEGINNING of the block that I want to select and delete.

A static text string that never changes is in the document and it
marks
the
END of the block that I want to select and delete.

The amount of text between the starting point and the ending point
(that
I
want to delete) varies with each document.

I need to be able to somehow use the Edit | Find to find that ending
string
and then select all of the text between the starting point and the
ending
point.

Does anyone know how to do this? If so, could you please write a
macro
and
post it? I'm sure that I could take your code and insert it into the
macro
editor and make the other changes that I need.

Thank you,

Alan



Back to top
Guest






PostPosted: Wed May 23, 2007 1:24 pm    Post subject: Re: Macro help needed please Reply with quote

"Alan B. Densky" <sales@neuro-vision.us> wrote in message
news:Oy8Wh.926$TD3.238@bignews5.bellsouth.net...
Quote:
Hello,

I'm using Word 2000.

I am trying to write a macro that will delete a specifi parts of a
document.

A static text string that never changes is in the document and it marks
the
BEGINNING of the block that I want to select and delete.

A static text string that never changes is in the document and it marks
the
END of the block that I want to select and delete.

The amount of text between the starting point and the ending point (that I
want to delete) varies with each document.

I need to be able to somehow use the Edit | Find to find that ending
string
and then select all of the text between the starting point and the ending
point.

Does anyone know how to do this? If so, could you please write a macro and
post it? I'm sure that I could take your code and insert it into the macro
editor and make the other changes that I need.

Thank you,

Alan

Hi if you just like macros for web base chat or games online

a cheats way of doing macros is use a little program called
shortkeys lite , it is free , cheers
>
Back to top
Len Robichaud
Guest





PostPosted: Thu Jun 07, 2007 2:01 pm    Post subject: Re: Inserting data from an ACCESS form into a bookmark in WO Reply with quote

First, Create a Command Button on your form
Then in the OnClick event, choose Code Builder and paste the following Sub

*************************************
Sub PopWordTemplate()
On Error GoTo PopWordTemplate_Error

Dim strTemplateFolder as string
Dim strTemplateFileName as string
Dim strTemplatePath As String
Dim objWord As Word.Application
Dim docWord As Word.Document

'Open Word
On Error Resume Next
'If Word is already Open
Set objWord = GetObject(, "Word.Application")
'If Word is not Open, Open it
If Err.Number <> 0 Then 'Start Word
Set objWord = CreateObject("Word.Application")
End If

On Error GoTo PopWordTemplate_Error

'The following assumes the word template is in the same folder as your
Database
'If it is somewhere else replace the following with strTemplateFolder =
"your path here" (the quotes are required)
strTemplateFolder = Application.CurrentProject.Path

strTemplateFileName = "\"& "your Template Name" &".dot"
strTemplatePath = strTemplateFolder & strTemplateFileName

'Opens the template as a new doc and allows it to be viewed
objWord.Documents.Add Template:=strTemplateFile, NewTemplate:=False
objWord.Visible = True

With objWord
' Find a bookmark and replace it with something from your Open Form
.ActiveDocument.Bookmarks("MyBookmark1").Select
.Selection.Text = me!SomeFieldOnMyForm1
.ActiveDocument.Bookmarks("MyBookmark2").Select
.Selection.Text = me!SomeFieldOnMyForm2
End With

Exit Sub

PopWordTemplate_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
PopWordTemplate of Module basAutomation"
End Sub
*********************************
Len Robichaud

"Doctorjones_md" <xxxDoctorjones_mdxxx@xxxyahoo.com> wrote in message
news:%23akCoUWmHHA.4624@TK2MSFTNGP04.phx.gbl...
Quote:
I have the following code (which opens a NEW Word document and prints the
data from my ACCESS form) -- I need code that will open a specified WORD
template and insert the ACCESS data into a specific bookmark. I'm sure
this is a simple process, but I'm somewhat frazzled (at this point) and
have settled on this option over several previous suggestions. Here's the
code I need to modify:
==================================
'The following code outputs the Print Detail data to a NEW Word document

'On Error GoTo Err_Command83_Click

'Dim stDocName As String
'Dim MyForm As Form

'stDocName = "PrintDetails"
'Set MyForm = Screen.ActiveForm
'DoCmd.SelectObject acForm, stDocName, True
'DoCmd.PrintOut
'DoCmd.SelectObject acForm, MyForm.Name, False

'Exit_Command83_Click:
'Exit Sub

'Err_Command83_Click:
'MsgBox Err.Description
'Resume Exit_Command83_Click
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> word vba customization All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Computer Forum