- Remove From My Forums
-
Question
-
We have a macro we run to format the page for our publisher. There are several documents that use this macro. For smaller documents the macro runs without error, for larger documents we receive the error in the subject line of this thread.
Small document — <= 256KB
Large document — >= 500KB
For the documents that have the error I can open them in Word and manually make the settings without a problem.
Here is the macro
Sub pagestuffB() ' ' Format for Publisher ' ' With Application .Options.Pagination = False .ScreenUpdating = False With .ActiveDocument.PageSetup .PageWidth = InchesToPoints(8.5) ' <<---- Runtime Error 4608, Value out of range here .PageHeight = InchesToPoints(11) .Orientation = wdOrientPortrait .LineNumbering.Active = False .TopMargin = InchesToPoints(1.34) .HeaderDistance = InchesToPoints(0.98) .BottomMargin = InchesToPoints(1) .FooterDistance = InchesToPoints(0.8) .LeftMargin = InchesToPoints(1.61) .RightMargin = InchesToPoints(1.4) .Gutter = InchesToPoints(0) .FirstPageTray = wdPrinterDefaultBin .OtherPagesTray = wdPrinterDefaultBin .SectionStart = wdSectionContinuous .OddAndEvenPagesHeaderFooter = True .DifferentFirstPageHeaderFooter = True .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = True .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With End With End Sub
«Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it.» — MSDN User JohnWein
Multics — An OS ahead of its time.
-
Edited by
Tuesday, March 22, 2016 6:25 PM
-
Edited by
Answers
-
Hi dbasnett,
With your document, I could get the same error. I think this issue is related with there are multiple sections in your document. And I would agree with you to format each section individually. For long time, it might be related with your large document.
I suggest you try to use OpenXML sdk to format this document to check whether it will spend long time.
>> Insert file would be great if I could just figure out how to preserve the format of the document being inserted.
I found you have post a new thread for this issue, I suggest you keep follow this issue in the new thread.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.-
Proposed as answer by
Deepak Saradkumar PanchalMicrosoft contingent staff
Thursday, March 31, 2016 5:31 AM -
Marked as answer by
Deepak Saradkumar PanchalMicrosoft contingent staff
Thursday, March 31, 2016 5:31 AM
-
Proposed as answer by
0 / 0 / 0
Регистрация: 19.12.2014
Сообщений: 17
1
14.06.2018, 08:29. Показов 3141. Ответов 0
Привет! Данный код должен искать определенное слово в Word документе, по его «окружению» (rSearch, «дать*знания») в диапазоне двух заданных слов: (rStart, «Цель дисциплины») и (rEnd, «Задача дисциплины») и вставлять его в ячейку «C4», но вместо нужного слова, он вставляет весь текст документа и выдает ошибку: Run-time error ‘4608’: Значение лежит вне допустимого диапазона, жалуется на данную строчку: Set r = WordDoc.Range(r.End, r.End).
В чем проблема? Заранее спасибо.
Visual Basic | ||
|
__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь
0
LDMueller
-
#1
I have a macro which I created by recording the actual steps. This macro
basically takes a 3 page letter, for example and formats the first page to
print from our letterhead tray (tray 1) and all other pages to print from
bond paper tray (tray 3). Our printer is an HP Laserjet 4250.
My problem is this. Sometime’s my letter has different margins, etc. (I’m
assuming this is the problem) and because of this I get a Run-time error
‘4608: Value out of range error. When I try to Debug it, it will continually
error out on any of the lines under «With ActiveDocument.PageSetup».
I would sincerely appreciate some assistance since I really need to automate
the page setups for documents.
Sub letter1()
‘
‘ letter1 Macro
‘ Format document to print on Letterhad Paper with Bond for all following
pages
‘ Macro created 9/27/05 by Leigh Descher Mueller for CWA
‘
‘ Go to top of page
Selection.HomeKey Unit:=wdStory
‘ Select all
Selection.WholeStory
‘ Page setup, apply to Whole document,
‘ First page = Tray 3, Other pages = Tray 3
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = «»
End If
.NameFarEast = «»
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(1)
.FooterDistance = InchesToPoints(1)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = 260
.OtherPagesTray = 260
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = True
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = True
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
‘Go Home
Selection.HomeKey Unit:=wdStory
‘ F8, go to Page 2
Selection.Extend
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=»2″
Selection.Find.ClearFormatting
With Selection.Find
.Text = «»
.Replacement.Text = «»
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
‘ Page setup, Apply to Selected sections,
‘ First page = Tray 1, Other pages = Tray 3
With Selection.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(1)
.FooterDistance = InchesToPoints(1)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = 262
.OtherPagesTray = 260
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = True
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = True
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
‘Go Home
Selection.HomeKey Unit:=wdStory
End Sub
Advertisements
Casey Mac
-
#2
I have the exact same error on my code: I hope some one can help. im using
word 2003
ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True
Set oRng = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
oRng.ParagraphFormat.Alignment = wdAlignParagraphCenter
NormalTemplate.AutoTextEntries(«Page X of Y»).Insert Where:=oRng,
RichText:=True
Jean-Guy Marcil
-
#3
Casey Mac was telling us:
Casey Mac nous racontait que :
I have the exact same error on my code: I hope some one can help. im
using word 2003ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True
Set oRng =
ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
oRng.ParagraphFormat.Alignment = wdAlignParagraphCenter
NormalTemplate.AutoTextEntries(«Page X of Y»).Insert Where:=oRng,
RichText:=True
Your code ran fine as is (Word 2003) on my machine.
By the way, you may be experiencing the same error message as the OP, but it
is definitely a different problem. It would be better to start a new
thread…
—
Salut!
_______________________________________
Jean-Guy Marcil — Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
Jean-Guy Marcil
-
#4
LDMueller was telling us:
LDMueller nous racontait que :
I have a macro which I created by recording the actual steps. This
macro basically takes a 3 page letter, for example and formats the
first page to print from our letterhead tray (tray 1) and all other
pages to print from bond paper tray (tray 3). Our printer is an HP
Laserjet 4250.My problem is this. Sometime’s my letter has different margins, etc.
(I’m assuming this is the problem) and because of this I get a
Run-time error ‘4608: Value out of range error. When I try to Debug
it, it will continually error out on any of the lines under «With
ActiveDocument.PageSetup».I would sincerely appreciate some assistance since I really need to
automate the page setups for documents.
First, I would suggest that you clean up your macro…
See
http://word.mvps.org/faqs/macrosvba/ModifyRecordedMacro.htm
—
Salut!
_______________________________________
Jean-Guy Marcil — Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
LDMueller
-
#5
Thank your for your response. This information was very helpful, however, I
had cleaned it up initally and when it didn’t work, I put everything back in.
The following is my updated code, however it still doesn’t work. We have
Word 2003 and our printer is an HP Laserjet 4250.
Selection.WholeStory
With ActiveDocument.PageSetup
.FirstPageTray = 262
.OtherPagesTray = 260
End With
Thanks!
Jean-Guy Marcil
-
#6
LDMueller was telling us:
LDMueller nous racontait que :
Thank your for your response. This information was very helpful,
however, I had cleaned it up initally and when it didn’t work, I put
everything back in.The following is my updated code, however it still doesn’t work. We
have Word 2003 and our printer is an HP Laserjet 4250.Selection.WholeStory
With ActiveDocument.PageSetup
.FirstPageTray = 262
.OtherPagesTray = 260
End With
How did you get those tray constants? (262, 260)
Those are printer specific, not Word specific.
—
Salut!
_______________________________________
Jean-Guy Marcil — Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
Advertisements
LDMueller
-
#7
Those are the constants that came up after recording the macro setting the
paper sized for that particular printer.
Jean-Guy Marcil
LDMueller
-
#9
Yes, I saw that article awhile back. I tried using it and it did have a
window showing paper sizes, but I didn’t really know what to do with the
information. This still didn’t help me write a macro that worked.
Thanks anyway.
Advertisements
Jean-Guy Marcil
Вы не вошли. Пожалуйста, войдите или зарегистрируйтесь.
Страницы 1
Чтобы отправить ответ, вы должны войти или зарегистрироваться
Сообщений [ 3 ]
1 09.09.2016 14:07:12
- mikkelle
- полковник
- Неактивен
- Зарегистрирован: 21.01.2010
- Сообщений: 227
- Поблагодарили: 12
Тема: Ошибка 4608 при выполнении макроса из VBA
Всех приветствую.
Может кто то раньше сталкивался с подобными выкрутасами ворда и знает где рыть? Ворд 2010, Винда 7, все последние обновления стоят. Имеется файл ворда формата doc полученный со стороны.
При установке значений размера бумаги и ориентации страниц, единых для всего документа(например А4, портрет) через форму «Параметры страницы» все изменения принимаются нормально.
Если запускать макрос, записанный при выполнении предыдущих изменений, он выдает ошибку 4608 «Значение лежит вне допустимого диапазона».
Проблемный файл прилагаю. Код самозаписанного макроса в файле.
Post’s attachments
Документ.rar 18.84 Кб, 6 скачиваний с 2016-09-09
You don’t have the permssions to download the attachments of this post.
2 Ответ от Fck_This 12.09.2016 09:43:16
- Fck_This
- генерал-полковник
- Неактивен
- Откуда: Минск, Беларусь
- Зарегистрирован: 13.07.2016
- Сообщений: 648
- Поблагодарили: 97
Re: Ошибка 4608 при выполнении макроса из VBA
mikkelle пишет:
Всех приветствую.
Может кто то раньше сталкивался с подобными выкрутасами ворда и знает где рыть? Ворд 2010, Винда 7, все последние обновления стоят. Имеется файл ворда формата doc полученный со стороны.
При установке значений размера бумаги и ориентации страниц, единых для всего документа(например А4, портрет) через форму «Параметры страницы» все изменения принимаются нормально.
Если запускать макрос, записанный при выполнении предыдущих изменений, он выдает ошибку 4608 «Значение лежит вне допустимого диапазона».
Проблемный файл прилагаю. Код самозаписанного макроса в файле.
Может просто код выложите отдельно? ошибку выбивает при распаковке.
Спасибо можно перевести на WebMoney-кошелёк R378231864568 или на Яндекс-деньги 410015093172871
3 Ответ от mikkelle 13.09.2016 10:19:01
- mikkelle
- полковник
- Неактивен
- Зарегистрирован: 21.01.2010
- Сообщений: 227
- Поблагодарили: 12
Re: Ошибка 4608 при выполнении макроса из VBA
Fck_This пишет:
ошибку выбивает при распаковке.
Не знаю, проверил, все нормально скачивается и распаковывается.
Код самый незамысловатый. Привожу как его создала макрорекодер. Первую же ошибку выдает на строке
.LineNumbering.Active = False
Sub Макрос1()
'
' Макрос1 Макрос
'
'
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.Gutter = MillimetersToPoints(0)
.PageWidth = MillimetersToPoints(210)
.PageHeight = MillimetersToPoints(297)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionContinuous
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
End Sub
Сообщений [ 3 ]
Страницы 1
Чтобы отправить ответ, вы должны войти или зарегистрироваться
Похожие темы
- vba ошибка при переходе на новую строку при выполнении макроса
- Ошибка при запуске макроса
- Ошибка 5852 при работе макроса, помечающего исправления
- Ошибка!
- Ошибка 4680. wdDialogFormatDrawingObject
- Ошибка при удалении стилей
- Ошибка подсчёта страниц
- При отправке на печать — ошибка
Ошибка 4608 при выполнении макроса из VBA
Для работы с текстами пока не придумали ничего лучше, чем редактор Microcoft Word. Для работы с большими объемами текстов нет ничего лучше, чем средства автоматизации этого редактора. На портале о Microsoft Office Word вы узнаете про: word 2010 сервис.
Но если основные функции Ворда можно легко освоить самому, то тут требуется уже помощь и совет опытных пользователей. На портале о Microsoft Office Word вы узнаете про: содержание документа word.
Все это вы найдете на форуме сайта Ворд Эксперт.
На форуме просто и доступно объясняется, как создавать макросы в автоматическом режиме, писать макросы и шаблоны для различных задач, стоящих перед пользователем, какие настройки лучше выбрать для оптимизации той либо иной операции. На портале о Microsoft Office Word вы узнаете про: как поставить птичку в word.
Кроме того, участники форума делятся своими наработками и готовыми решениями, принимают заказы на любые разработки, связанные с Вордом. Наш сайт о Microsoft Office Word даст ответ про: границы и заливка в 2007.
Forum Rules |
|
This site uses cookies.
Some of these cookies are essential to the operation of the site,
while others help to improve your experience by providing insights into how the site is being used.
For more information, please see the ProZ.com privacy policy.
Технические форумы » Wordfast support » |
|
runtime error 4608 Автор темы: Roberte de Waha |
||||||||
---|---|---|---|---|---|---|---|---|
Roberte de Waha
|
||||||||
Dominique Pivard
|
||||||||
Vico Terzi
|
Login to reply/comment
To report site rules violations or get help, contact a site moderator:
Модератор(ы) этого форума | |
Natalie | [Call to this topic] |
Marco Ramón | [Call to this topic] |
Prachya Mruetusatorn | [Call to this topic] |
You can also contact site staff by submitting a support request »
runtime error 4608
Advanced search
» Wordfast Provides Free Access to Coronavirus Translation Memories
(0 comments)
Submit translation news about Wordfast »
Read more translation news »
Forum rules
Help and orientation
|
||
|