Runtime error 4198 ошибка команды vba

I have been trying to write a word VBA script that uses a screenshot (already copied to the clipboard) and pastes it into a word document to be formatted and saved. The program works great on my computer at work, but when I distributed it to others, it failed to work on about 25% of the computers. The error that I received was «4198 Runtime Error». I have searched for similar problems that other people have had, but I am still at a loss. All of the computers in the office run the same version of work, 2010 standard version.

The issue is with the very last line of code, selection.paste.
I did make sure that they had a screenshot on their clipboard before running the script.

Thank you so much for any and all input.

Sub MapMaker()

'set up new document with narrow margins and landscape orientation
With Selection.PageSetup
    .LineNumbering.Active = False
    .Orientation = wdOrientPortrait
    .TopMargin = InchesToPoints(0.5)
    .BottomMargin = InchesToPoints(0.5)
    .LeftMargin = InchesToPoints(0.5)
    .RightMargin = InchesToPoints(0.5)
    .Gutter = InchesToPoints(0)
    .HeaderDistance = InchesToPoints(0.5)
    .FooterDistance = InchesToPoints(0.5)
    .PageWidth = InchesToPoints(8.5)
    .PageHeight = InchesToPoints(11)
    .FirstPageTray = wdPrinterDefaultBin
    .OtherPagesTray = wdPrinterDefaultBin
    .SectionStart = wdSectionNewPage
    .OddAndEvenPagesHeaderFooter = False
    .DifferentFirstPageHeaderFooter = False
    .VerticalAlignment = wdAlignVerticalTop
    .SuppressEndnotes = False
    .MirrorMargins = False
    .TwoPagesOnOne = False
    .BookFoldPrinting = False
    .BookFoldRevPrinting = False
    .BookFoldPrintingSheets = 1
    .GutterPos = wdGutterPosLeft
End With
If Selection.PageSetup.Orientation = wdOrientPortrait Then
    Selection.PageSetup.Orientation = wdOrientLandscape
Else
    Selection.PageSetup.Orientation = wdOrientPortrait
End If
' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

'paste and resize screenshot to full page width
Selection.Paste

Luuklag's user avatar

Luuklag

3,90511 gold badges38 silver badges57 bronze badges

asked Aug 11, 2014 at 16:17

mcf_reilly's user avatar

3

4198 Runtime Error might associate with links. If you have links on your origin word document where it is being printscreened, try remove it and see if that solve the problem.

answered Aug 11, 2014 at 21:13

Alex's user avatar

AlexAlex

1,6321 gold badge12 silver badges28 bronze badges

XoFfiCEr

исследователь

325 / 104 / 3

Регистрация: 18.03.2010

Сообщений: 1,079

Записей в блоге: 2

1

Найти ошибку в процедуре

29.11.2010, 15:57. Показов 5752. Ответов 29

Метки нет (Все метки)


Студворк — интернет-сервис помощи студентам

Ниже процедура, она выполняет удаление активных гиперссылок, в файлах найденных другой процедурой в заданной папке. (все это в форме) Она работает нормально до .Hyperlinks.Item(1).Delete и выбивает ошибку.
«Run-time error ‘4198’» Ошибка команды.
Что не правильно?, я бьюсь уже давно не могу понять.

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Sub KillHyperLinks()
For i = 1 To qfiles
docname = files(i)
Documents.Open FileName:=docname, ReadOnly:=False
With ActiveDocument
.Activate
qlinks = .Hyperlinks.Count
If qlinks = 0 Then
    GoTo nx
End If
While .Hyperlinks.Count > 0
'MsgBox .Hyperlinks.Count
.Hyperlinks.Item(1).Delete
dellinks = dellinks + 1
Wend
ActiveWindow.ActivePane.View.Type = wdPrintView
.Save
End With
nx: ActiveDocument.Close
 Next i
End Sub



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

29.11.2010, 15:57

Ответы с готовыми решениями:

Исправить ошибку в процедуре
Исправить ошибку в процедуре: Инструкция Select Case в следующей процедуре должна выводить окно…

найти ошибку в процедуре
Была программа
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes,…

Найти ошибку в процедуре
Задание следующее:
Создать процедуру с использованием курсора для вывода списка занятий…

Найти ошибку в процедуре
Даны два одномерных массива длиной n. Поменять местами 1-й и последний элементы в каждом массиве….

29

128 / 23 / 3

Регистрация: 23.09.2010

Сообщений: 62

29.11.2010, 16:43

2

Цитата
Сообщение от <Профессор>
Посмотреть сообщение

активных гиперссылок

а ещё какие есть гиперссылки?

То есть надо из другой программы удалить все гиперссылки из документа Word?



0



Helen_fire

204 / 43 / 6

Регистрация: 15.10.2010

Сообщений: 125

29.11.2010, 17:00

3

Лучший ответ Сообщение было отмечено как решение

Решение

Ошибка в логике программы. нужно еще ввести переменную qlinks внутрь цикла и с каждым удалением ссылки уменьшать ее на 1 и сравнивать с нулем, т.к. цикл While у Вас бесконечен, а ссылок с каждым шагом становится на 1 меньше, вот он и приходит к тому, что надо удалять, а удалять нечего. Поэтому и сравнение qlinks с нулем и закрытие документа надо перенести внутрь цикла.

Или сделать так:

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Sub KillHyperLinks()
For i = 1 To qfiles
docname = files(i)
Documents.Open FileName:=docname, ReadOnly:=False
With ActiveDocument
.Activate
qlinks = .Hyperlinks.Count
If qlinks = 0 Then
    GoTo nx
End If
While qlinks > 0
'MsgBox .Hyperlinks.Count
.Hyperlinks.Item(1).Delete
qlinks= qlinks-1
dellinks = dellinks + 1
Wend
ActiveWindow.ActivePane.View.Type = wdPrintView
.Save
End With
nx: ActiveDocument.Close
 Next i
End Sub



2



исследователь

325 / 104 / 3

Регистрация: 18.03.2010

Сообщений: 1,079

Записей в блоге: 2

29.11.2010, 17:33

 [ТС]

4

Цитата
Сообщение от Terminators
Посмотреть сообщение

а ещё какие есть гиперссылки?

То есть надо из другой программы удалить все гиперссылки из документа Word?

Как это какие? Это когда просто Url в тексте написан, как обычно в колонтитулах пишут.



0



Busine2009

Заблокирован

29.11.2010, 19:42

5

Цитата
Сообщение от <Профессор>
Посмотреть сообщение

Это когда просто Url в тексте написан

это не является гиперссылкой.



0



218 / 50 / 2

Регистрация: 18.02.2010

Сообщений: 82

29.11.2010, 20:56

6

Попроще бы надо:

Код

Sub KillHyperLinks()
Dim i&, k&, S$
    For i = 1 To QFiles
        S = Files(i)
        With Documents.Open(FileName:=S, Visible:=False)
            For k = .Hyperlinks.Count To 1 Step -1
                .Hyperlinks(k).Delete
            Next k
            .Close wdSaveChanges
        End With
    Next i   
End Sub

Устранено два прилично тормозящих фактора:
— видимость документа (добавлено Visible)
— пересохранение документа при отсутствии изменений (удалено Save)



1



исследователь

325 / 104 / 3

Регистрация: 18.03.2010

Сообщений: 1,079

Записей в блоге: 2

02.12.2010, 01:21

 [ТС]

7

Цитата
Сообщение от Busine2009
Посмотреть сообщение

это не является гиперссылкой.

ну может и не является
но заказчик просил удалить только активные ссылки
а по опыту работы на госслужбе могу сказать что написанный url могут все же считать гиперссылкой, несмотря на все каноны VBA.



0



Busine2009

Заблокирован

02.12.2010, 01:26

8

Цитата
Сообщение от <Профессор>
Посмотреть сообщение

что написанный url могут все же считать гиперссылкой, несмотря на все каноны VBA.

Полный бред.

Добавлено через 1 минуту

Цитата
Сообщение от <Профессор>
Посмотреть сообщение

.Hyperlinks.Item(1).Delete

и это не удаление текста — это превращение гиперссылки просто в текст.



0



XoFfiCEr

исследователь

325 / 104 / 3

Регистрация: 18.03.2010

Сообщений: 1,079

Записей в блоге: 2

02.12.2010, 01:27

 [ТС]

9

Цитата
Сообщение от Helen_fire
Посмотреть сообщение

Ошибка в логике программы. нужно еще ввести переменную qlinks внутрь цикла и с каждым удалением ссылки уменьшать ее на 1 и сравнивать с нулем, т.к. цикл While у Вас бесконечен, а ссылок с каждым шагом становится на 1 меньше, вот он и приходит к тому, что надо удалять, а удалять нечего. Поэтому и сравнение qlinks с нулем и закрытие документа надо перенести внутрь цикла.

Или сделать так:

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Sub KillHyperLinks()
For i = 1 To qfiles
docname = files(i)
Documents.Open FileName:=docname, ReadOnly:=False
With ActiveDocument
.Activate
qlinks = .Hyperlinks.Count
If qlinks = 0 Then
    GoTo nx
End If
While qlinks > 0
'MsgBox .Hyperlinks.Count
.Hyperlinks.Item(1).Delete
qlinks= qlinks-1
dellinks = dellinks + 1
Wend
ActiveWindow.ActivePane.View.Type = wdPrintView
.Save
End With
nx: ActiveDocument.Close
 Next i
End Sub

А все равно не работает, все та же ошибка!

Добавлено через 1 минуту

Цитата
Сообщение от Busine2009
Посмотреть сообщение

Полный бред.

Добавлено через 1 минуту

и это не удаление текста — это превращение гиперссылки просто в текст.

Нет он удаляет полностью текст гиперссылки я проверял



0



Busine2009

Заблокирован

02.12.2010, 01:28

10

Цитата
Сообщение от <Профессор>
Посмотреть сообщение

Нет он удаляет полностью текст гиперссылки я проверял

Код

.Hyperlinks.Item(1).Delete

не удаляет текст.



0



исследователь

325 / 104 / 3

Регистрация: 18.03.2010

Сообщений: 1,079

Записей в блоге: 2

02.12.2010, 01:31

 [ТС]

11

Цитата
Сообщение от Busine2009
Посмотреть сообщение

Код

.Hyperlinks.Item(1).Delete

не удаляет текст.

Реально вообще ничего не удаляет. Выводит сообщение об ошибке. Останавливается выполнение именно на этой строке.



0



Busine2009

Заблокирован

02.12.2010, 01:32

12

<Профессор>,
тебе ответили в чём причина. Завтра гляну. Ты не бухаешь сейчас?



0



исследователь

325 / 104 / 3

Регистрация: 18.03.2010

Сообщений: 1,079

Записей в блоге: 2

02.12.2010, 01:46

 [ТС]

13

Цитата
Сообщение от Busine2009
Посмотреть сообщение

<Профессор>,
тебе ответили в чём причина. Завтра гляну. Ты не бухаешь сейчас?

Фигасе почему сразу бухаешь? Нет не бухаю. Да вот не помогли ваши ответы. Мой код правильно работает со всеми документами кроме трех, что с ними такое блин?!

Добавлено через 12 минут

Цитата
Сообщение от Вождь
Посмотреть сообщение

Попроще бы надо:

Код

Sub KillHyperLinks()
Dim i&, k&, S$
    For i = 1 To QFiles
        S = Files(i)
        With Documents.Open(FileName:=S, Visible:=False)
            For k = .Hyperlinks.Count To 1 Step -1
                .Hyperlinks(k).Delete
            Next k
            .Close wdSaveChanges
        End With
    Next i   
End Sub

Устранено два прилично тормозящих фактора:
— видимость документа (добавлено Visible)
— пересохранение документа при отсутствии изменений (удалено Save)

И этот вариант тоже не работает Все та же ошибка.



0



Busine2009

Заблокирован

02.12.2010, 06:56

14

<Профессор>,
а какой ты в итоге код использовать хочешь?



0



218 / 50 / 2

Регистрация: 18.02.2010

Сообщений: 82

02.12.2010, 07:11

15

Ошибка возникает не по вине макроса. В обычных условиях вышеописанные макросы полностью рабочие. Вам надо внимательней присмотреться к документам и вообще к ситуации.

Ошибка ошибкой, а гиперссылки то удаляются? Попробуйте добавить On Error Resume Next.

Об ошибке: «Run-time error ‘4198’»
Application-defined or object-defined error

This message is displayed when an error generated with the Raise method or Error statement doesn’t correspond to an error defined by Visual Basic for Applications.

Это сообщение появляется, если ошибка вызвана методом Raise или случившаяся ошибка не соответствует ни одной ошибке из оговоренных в VBA.



1



исследователь

325 / 104 / 3

Регистрация: 18.03.2010

Сообщений: 1,079

Записей в блоге: 2

02.12.2010, 07:27

 [ТС]

16

Цитата
Сообщение от Busine2009
Посмотреть сообщение

<Профессор>,
а какой ты в итоге код использовать хочешь?

Свой конечно, он протестирован причем в присутствии заказчика на многих документах



0



Busine2009

Заблокирован

02.12.2010, 07:52

17

<Профессор>,
выясни, на какой гиперссылке происходит эта ошибка.

Вот так можно обработать ошибку, если решение не будет найдено:

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Sub m_2()
    On Error Resume Next
    Do While ActiveDocument.Hyperlinks.Count > 0
        ActiveDocument.Hyperlinks(1).Delete
        If Err.Number <> 0 And Err.Number <> 4198 Then
            GoTo metka
        End If
        On Error GoTo 0
    Loop
    If ActiveDocument.Hyperlinks.Count > 0 Then
        MsgBox "Часть гиперссылок не удалось удалить из документа." & vbCr & "Удалите их вручную."
    End If
    Exit Sub
metka:
    MsgBox "Возникла новая ошибка"
End Sub



0



XoFfiCEr

исследователь

325 / 104 / 3

Регистрация: 18.03.2010

Сообщений: 1,079

Записей в блоге: 2

02.12.2010, 20:07

 [ТС]

18

Цитата
Сообщение от Busine2009
Посмотреть сообщение

<Профессор>,
выясни, на какой гиперссылке происходит эта ошибка.

Вот так можно обработать ошибку, если решение не будет найдено:

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Sub m_2()
    On Error Resume Next
    Do While ActiveDocument.Hyperlinks.Count > 0
        ActiveDocument.Hyperlinks(1).Delete
        If Err.Number <> 0 And Err.Number <> 4198 Then
            GoTo metka
        End If
        On Error GoTo 0
    Loop
    If ActiveDocument.Hyperlinks.Count > 0 Then
        MsgBox "Часть гиперссылок не удалось удалить из документа." & vbCr & "Удалите их вручную."
    End If
    Exit Sub
metka:
    MsgBox "Возникла новая ошибка"
End Sub

Слушай зачем все это? Мне не нужен этот код, мне нужна чтоб эта процедура удаляла активные гиперссылки, а не выводила сообщения о том сто их не удалось удалить.

Не по теме:

оскорблен



0



Busine2009

Заблокирован

02.12.2010, 20:21

19

Цитата
Сообщение от <Профессор>
Посмотреть сообщение

.Hyperlinks.Item(1).Delete

ты целенаправленно используешь

Visual Basic
1
Item

?
С какой целью ты используешь этот метод (Item)?
Попробуй без Item.
Я ещё ни разу его не использовал в своей практике. Сейчас пытаюсь понять, зачем он нужен.



0



XoFfiCEr

исследователь

325 / 104 / 3

Регистрация: 18.03.2010

Сообщений: 1,079

Записей в блоге: 2

02.12.2010, 20:31

 [ТС]

20

Цитата
Сообщение от Busine2009
Посмотреть сообщение

ты целенаправленно используешь

Visual Basic
1
Item

?
С какой целью ты используешь этот метод (Item)?
Попробуй без Item.
Я ещё ни разу его не использовал в своей практике. Сейчас пытаюсь понять, зачем он нужен.

Пробовал и без Item просто .Hyperlinks(1).Delete тот же результат.



0



  • Remove From My Forums
  • Question

  • Hi,

     I’m trying run a macro embedded in a Word document using C#, but Word pops up with the following error:

    Run-time error ‘4198’:
    Command Failed

    object m_fileName = "C:\\Users\\me\\AppData\\Local\\Project\\Cache\\ _SFD00_\\_SFD0000_Test.docx"; 
    object s_false = false;
    object s_missing = System.Reflection.Missing.Value;
    m_wordApp.Run("FileSaveAs", ref m_fileName, ref s_false, ref s_missing, ref s_missing, ref s_missing, ref s_missing,
    ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing,
    ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing,
    ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing, ref s_missing);
    Public Sub FileSaveAs(ByRef filePath, ByRef falseObj)
    '
    ' FileSaveAs Macro
    ' Saves a copy of the document in a separate file
    '
    ActiveDocument.SaveAs FileName:=filePath, AddToRecentFiles:=falseObj
    End Sub

    It fails at ActiveDocument.SaveAs
    line. I’ve checked the file path while debugging the macro and it looks the same as the above minus the double slashes. Also I have very little experience with Visual Basic, so I’m not sure if I’m doing something wrong there. Any help would
    be appreciated and sorry for some of the crazy page formatting.

    Thanks,

    chrrug1524

Answers

  • Hi chrrug

    <<My only reasoning for trying to have the macro save the document was I thought maybe if I had something attached to the document directly the save would have more success, but obviously I was wrong.
    I’ve also had several threading issues throughout this whole process, so I’m not sure if maybe that is still the problem. >>

    OK, I think I’m with you, more or less. Office apps don’t really support «threading», so this could, indeed, be an issue. If you can take that out of the equation in a fairly simple manner for testing purposes,
    you should try that. It’s seems the most likely suspect, given the results of my other suggestions.

    It could also (and this would be related to threading) be a timing issue. Normally, using the Show method for a Windows Form should stop things and a Timer wouldn’t be necessary. Given the «threading», I
    can see where you might attempt using a Timer. But it’s possible that things still aren’t accessible (the document is still «locked» somehow).

    FWIW it’s possible to «repurpose» Word’s FileSaveAs dialog box to a limited extent, through late-binding. You can get the selected path and file name, and whether the user clicked Cancel…


    Cindy Meister, VSTO/Word MVP

    • Marked as answer by

      Monday, August 15, 2011 1:29 PM

I have problem with code below. On my PC itruns OK and generate PDF file from Word templates. I tried .rtf or .docx format of template doc. On PC at work I got

runtime error 4198 command failed.

On another PC (notebook) same error. On all PC’s I have installed Word and Excel.

Sub PdfEleDomVtNt()
    Dim wdDoc As Document
    Dim wdApp As Word.Application
    Set wdApp = New Word.Application
    Dim objField1 As Object
    Dim objField2 As Object
    Dim objField3 As Object
    Dim objField4 As Object
    Dim objField5 As Object
    Dim objField6 As Object
    Dim objField7 As Object
    Dim objField8 As Object
    Dim objField9 As Object
    Dim objField10 As Object
    Dim objField11 As Object
    Dim objField12 As Object
    Dim objField13 As Object
    Dim objField14 As Object
    Dim objField15 As Object
    Dim objField16 As Object
    Dim objField17 As Object
    Dim objField18 As Object
    Dim objField19 As Object
    Dim objField20 As Object
    Dim objField21 As Object
    Dim objField22 As Object
    Dim objField23 As Object
    Dim objField24 As Object
    Dim objField25 As Object
    Dim objField26 As Object
    Dim objField27 As Object
    Dim objField28 As Object
    Dim objField29 As Object
    Dim objField30 As Object
    Dim objField31 As Object
    Dim objField32 As Object
    Dim objField33 As Object
    
    ThisWorkbook.Sheets("vlozene_hodnoty").Range("B21").Dirty
    
    Dim pdfFileName As Variant
    
    If ThisWorkbook.Sheets("vlozene_hodnoty").Range("A20").Value = "" Then
    pdfFileName = ThisWorkbook.Path & "\" + Sheets("vlozene_hodnoty").Range("B23").Value + ".pdf"
    Else
    
    pdfFileName = ThisWorkbook.Sheets("vlozene_hodnoty").Range("A20").Value + "\" + ThisWorkbook.Sheets("vlozene_hodnoty").Range("B23").Value + ".pdf"
    End If
    
    wdApp.Visible = False 'Nastav hodtnotu Tru pro viditelnost aplikace Word
    On Error GoTo ErrHandler
    
    Set wdDoc = wdApp.Documents.Open(ThisWorkbook.Path & "\Templates\YELLO_Kalkulace_MOO_2T_ELE.rtf") 
    On Error GoTo 0
    
    Set objField1 = wdDoc.FormFields("Text1")
    Set objField2 = wdDoc.FormFields("Text2")
    Set objField3 = wdDoc.FormFields("Text3")
    Set objField4 = wdDoc.FormFields("Text4")
    Set objField5 = wdDoc.FormFields("Text5")
    Set objField6 = wdDoc.FormFields("Text6")
    Set objField7 = wdDoc.FormFields("Text7")
    Set objField8 = wdDoc.FormFields("Text8")
    Set objField9 = wdDoc.FormFields("Text9")
    Set objField10 = wdDoc.FormFields("Text10")
    Set objField11 = wdDoc.FormFields("Text11")
    Set objField12 = wdDoc.FormFields("Text12")
    Set objField13 = wdDoc.FormFields("Text13")
    Set objField14 = wdDoc.FormFields("Text14")
    Set objField15 = wdDoc.FormFields("Text15")
    Set objField16 = wdDoc.FormFields("Text16")
    Set objField17 = wdDoc.FormFields("Text17")
    Set objField18 = wdDoc.FormFields("Text18")
    Set objField19 = wdDoc.FormFields("Text19")
    Set objField20 = wdDoc.FormFields("Text20")
    Set objField21 = wdDoc.FormFields("Text21")
    Set objField22 = wdDoc.FormFields("Text22")
    Set objField23 = wdDoc.FormFields("Text23")
    Set objField24 = wdDoc.FormFields("Text24")
    Set objField25 = wdDoc.FormFields("Text25")
    Set objField26 = wdDoc.FormFields("Text26")
    Set objField27 = wdDoc.FormFields("Text27")
    Set objField28 = wdDoc.FormFields("Text28")
    Set objField29 = wdDoc.FormFields("Text29")
    Set objField30 = wdDoc.FormFields("Text30")
    Set objField31 = wdDoc.FormFields("Text31")
    Set objField32 = wdDoc.FormFields("Text32")
    Set objField33 = wdDoc.FormFields("Text33")
    
    objField1.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N3"), "# ###")
    objField2.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N4")
    objField3.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N5")
    objField4.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N6")
    objField5.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N7")
    objField6.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N8")
    objField7.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N9")
    objField8.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N10")
    objField9.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N11")
    objField10.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N12"), "### ###")
    objField11.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N13"), "### ###")
    objField12.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N14"), "# ###,##0.00") 
    objField13.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N15"), "# ###,##0.00") 
    objField14.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N16") 'frekvence
    objField15.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N17"), "### ###") 
    objField16.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N18"), "#,###0.000") 
    objField17.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N19"), "#,###0.000") 
    objField18.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N20"), "#,###0.000") 
    objField19.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N21"), "#,###0.000") 
    objField20.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N22"), "# ###,##0.00") 
    objField21.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N23"), "# ###,##0.00") 
    objField22.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N24"), "#,###0.000")
    objField23.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N25"), "#,###0.000")
    objField24.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N26"), "#,###0.000")
    objField25.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N27"), "#,###0.000")
    objField26.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N28"), "# ###,##0.00")
    objField27.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N29"), "# ###,##0.00")
    objField28.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N30"), "#,###0.000")
    objField29.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N31"), "#,###0.000")
    objField30.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N32"), "#,###0.000")
    objField31.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N33"), "#,###0.000")
    objField32.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N34"), "# ###,##0.00")
    objField33.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N35"), "# ###,##0.00")
    
    wdDoc.SaveAs pdfFileName, wdFormatPDF
    
    objField1.Result = ("")
    objField2.Result = ("")
    objField3.Result = ("")
    objField4.Result = ("")
    objField5.Result = ("")
    objField6.Result = ("")
    objField7.Result = ("")
    objField8.Result = ("")
    objField9.Result = ("")
    objField10.Result = ("")
    objField11.Result = ("")
    objField12.Result = ("")
    objField13.Result = ("")
    objField14.Result = ("")
    objField15.Result = ("")
    objField16.Result = ("")
    objField17.Result = ("")
    objField18.Result = ("")
    objField19.Result = ("")
    objField20.Result = ("")
    objField21.Result = ("")
    objField22.Result = ("")
    objField23.Result = ("")
    objField24.Result = ("")
    objField25.Result = ("")
    objField26.Result = ("")
    objField27.Result = ("")
    objField28.Result = ("")
    objField29.Result = ("")
    objField30.Result = ("")
    objField31.Result = ("")
    objField32.Result = ("")
    objField33.Result = ("")
    
    wdDoc.Close
    wdApp.Quit
    
    Shell "rundll32.exe url.dll,FileProtocolHandler " & pdfFileName, vbNormalFocus
    Exit Sub

ErrHandler:
    MsgBox "Soubor se šablonou se nepodařilo otevřít. Zkontrolujte cestu a název souboru.", vbCritical
End Sub

I checked references in VBA, changing doc type of template but I am at the end. I also try google runtime error 4198 but nothing what help me. Error shows up on line with code «wdDoc.SaveAs pdfFileName, wdFormatPDF» but as I said only on work PC or notebook.

I have been trying to write a word VBA script that uses a screenshot (already copied to the clipboard) and pastes it into a word document to be formatted and saved. The program works great on my computer at work, but when I distributed it to others, it failed to work on about 25% of the computers. The error that I received was «4198 Runtime Error». I have searched for similar problems that other people have had, but I am still at a loss. All of the computers in the office run the same version of work, 2010 standard version.

The issue is with the very last line of code, selection.paste.
I did make sure that they had a screenshot on their clipboard before running the script.

Thank you so much for any and all input.

Sub MapMaker()

'set up new document with narrow margins and landscape orientation
With Selection.PageSetup
    .LineNumbering.Active = False
    .Orientation = wdOrientPortrait
    .TopMargin = InchesToPoints(0.5)
    .BottomMargin = InchesToPoints(0.5)
    .LeftMargin = InchesToPoints(0.5)
    .RightMargin = InchesToPoints(0.5)
    .Gutter = InchesToPoints(0)
    .HeaderDistance = InchesToPoints(0.5)
    .FooterDistance = InchesToPoints(0.5)
    .PageWidth = InchesToPoints(8.5)
    .PageHeight = InchesToPoints(11)
    .FirstPageTray = wdPrinterDefaultBin
    .OtherPagesTray = wdPrinterDefaultBin
    .SectionStart = wdSectionNewPage
    .OddAndEvenPagesHeaderFooter = False
    .DifferentFirstPageHeaderFooter = False
    .VerticalAlignment = wdAlignVerticalTop
    .SuppressEndnotes = False
    .MirrorMargins = False
    .TwoPagesOnOne = False
    .BookFoldPrinting = False
    .BookFoldRevPrinting = False
    .BookFoldPrintingSheets = 1
    .GutterPos = wdGutterPosLeft
End With
If Selection.PageSetup.Orientation = wdOrientPortrait Then
    Selection.PageSetup.Orientation = wdOrientLandscape
Else
    Selection.PageSetup.Orientation = wdOrientPortrait
End If
' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

'paste and resize screenshot to full page width
Selection.Paste

I have problem with code below. On my PC itruns OK and generate PDF file from Word templates. I tried .rtf or .docx format of template doc. On PC at work I got

runtime error 4198 command failed.

On another PC (notebook) same error. On all PC’s I have installed Word and Excel.

Sub PdfEleDomVtNt()
    Dim wdDoc As Document
    Dim wdApp As Word.Application
    Set wdApp = New Word.Application
    Dim objField1 As Object
    Dim objField2 As Object
    Dim objField3 As Object
    Dim objField4 As Object
    Dim objField5 As Object
    Dim objField6 As Object
    Dim objField7 As Object
    Dim objField8 As Object
    Dim objField9 As Object
    Dim objField10 As Object
    Dim objField11 As Object
    Dim objField12 As Object
    Dim objField13 As Object
    Dim objField14 As Object
    Dim objField15 As Object
    Dim objField16 As Object
    Dim objField17 As Object
    Dim objField18 As Object
    Dim objField19 As Object
    Dim objField20 As Object
    Dim objField21 As Object
    Dim objField22 As Object
    Dim objField23 As Object
    Dim objField24 As Object
    Dim objField25 As Object
    Dim objField26 As Object
    Dim objField27 As Object
    Dim objField28 As Object
    Dim objField29 As Object
    Dim objField30 As Object
    Dim objField31 As Object
    Dim objField32 As Object
    Dim objField33 As Object
    
    ThisWorkbook.Sheets("vlozene_hodnoty").Range("B21").Dirty
    
    Dim pdfFileName As Variant
    
    If ThisWorkbook.Sheets("vlozene_hodnoty").Range("A20").Value = "" Then
    pdfFileName = ThisWorkbook.Path & "" + Sheets("vlozene_hodnoty").Range("B23").Value + ".pdf"
    Else
    
    pdfFileName = ThisWorkbook.Sheets("vlozene_hodnoty").Range("A20").Value + "" + ThisWorkbook.Sheets("vlozene_hodnoty").Range("B23").Value + ".pdf"
    End If
    
    wdApp.Visible = False 'Nastav hodtnotu Tru pro viditelnost aplikace Word
    On Error GoTo ErrHandler
    
    Set wdDoc = wdApp.Documents.Open(ThisWorkbook.Path & "TemplatesYELLO_Kalkulace_MOO_2T_ELE.rtf") 
    On Error GoTo 0
    
    Set objField1 = wdDoc.FormFields("Text1")
    Set objField2 = wdDoc.FormFields("Text2")
    Set objField3 = wdDoc.FormFields("Text3")
    Set objField4 = wdDoc.FormFields("Text4")
    Set objField5 = wdDoc.FormFields("Text5")
    Set objField6 = wdDoc.FormFields("Text6")
    Set objField7 = wdDoc.FormFields("Text7")
    Set objField8 = wdDoc.FormFields("Text8")
    Set objField9 = wdDoc.FormFields("Text9")
    Set objField10 = wdDoc.FormFields("Text10")
    Set objField11 = wdDoc.FormFields("Text11")
    Set objField12 = wdDoc.FormFields("Text12")
    Set objField13 = wdDoc.FormFields("Text13")
    Set objField14 = wdDoc.FormFields("Text14")
    Set objField15 = wdDoc.FormFields("Text15")
    Set objField16 = wdDoc.FormFields("Text16")
    Set objField17 = wdDoc.FormFields("Text17")
    Set objField18 = wdDoc.FormFields("Text18")
    Set objField19 = wdDoc.FormFields("Text19")
    Set objField20 = wdDoc.FormFields("Text20")
    Set objField21 = wdDoc.FormFields("Text21")
    Set objField22 = wdDoc.FormFields("Text22")
    Set objField23 = wdDoc.FormFields("Text23")
    Set objField24 = wdDoc.FormFields("Text24")
    Set objField25 = wdDoc.FormFields("Text25")
    Set objField26 = wdDoc.FormFields("Text26")
    Set objField27 = wdDoc.FormFields("Text27")
    Set objField28 = wdDoc.FormFields("Text28")
    Set objField29 = wdDoc.FormFields("Text29")
    Set objField30 = wdDoc.FormFields("Text30")
    Set objField31 = wdDoc.FormFields("Text31")
    Set objField32 = wdDoc.FormFields("Text32")
    Set objField33 = wdDoc.FormFields("Text33")
    
    objField1.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N3"), "# ###")
    objField2.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N4")
    objField3.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N5")
    objField4.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N6")
    objField5.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N7")
    objField6.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N8")
    objField7.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N9")
    objField8.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N10")
    objField9.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N11")
    objField10.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N12"), "### ###")
    objField11.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N13"), "### ###")
    objField12.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N14"), "# ###,##0.00") 
    objField13.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N15"), "# ###,##0.00") 
    objField14.Result = ThisWorkbook.Sheets("vlozene_hodnoty").Range("N16") 'frekvence
    objField15.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N17"), "### ###") 
    objField16.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N18"), "#,###0.000") 
    objField17.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N19"), "#,###0.000") 
    objField18.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N20"), "#,###0.000") 
    objField19.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N21"), "#,###0.000") 
    objField20.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N22"), "# ###,##0.00") 
    objField21.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N23"), "# ###,##0.00") 
    objField22.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N24"), "#,###0.000")
    objField23.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N25"), "#,###0.000")
    objField24.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N26"), "#,###0.000")
    objField25.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N27"), "#,###0.000")
    objField26.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N28"), "# ###,##0.00")
    objField27.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N29"), "# ###,##0.00")
    objField28.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N30"), "#,###0.000")
    objField29.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N31"), "#,###0.000")
    objField30.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N32"), "#,###0.000")
    objField31.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N33"), "#,###0.000")
    objField32.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N34"), "# ###,##0.00")
    objField33.Result = Format(ThisWorkbook.Sheets("vlozene_hodnoty").Range("N35"), "# ###,##0.00")
    
    wdDoc.SaveAs pdfFileName, wdFormatPDF
    
    objField1.Result = ("")
    objField2.Result = ("")
    objField3.Result = ("")
    objField4.Result = ("")
    objField5.Result = ("")
    objField6.Result = ("")
    objField7.Result = ("")
    objField8.Result = ("")
    objField9.Result = ("")
    objField10.Result = ("")
    objField11.Result = ("")
    objField12.Result = ("")
    objField13.Result = ("")
    objField14.Result = ("")
    objField15.Result = ("")
    objField16.Result = ("")
    objField17.Result = ("")
    objField18.Result = ("")
    objField19.Result = ("")
    objField20.Result = ("")
    objField21.Result = ("")
    objField22.Result = ("")
    objField23.Result = ("")
    objField24.Result = ("")
    objField25.Result = ("")
    objField26.Result = ("")
    objField27.Result = ("")
    objField28.Result = ("")
    objField29.Result = ("")
    objField30.Result = ("")
    objField31.Result = ("")
    objField32.Result = ("")
    objField33.Result = ("")
    
    wdDoc.Close
    wdApp.Quit
    
    Shell "rundll32.exe url.dll,FileProtocolHandler " & pdfFileName, vbNormalFocus
    Exit Sub

ErrHandler:
    MsgBox "Soubor se šablonou se nepodařilo otevřít. Zkontrolujte cestu a název souboru.", vbCritical
End Sub

I checked references in VBA, changing doc type of template but I am at the end. I also try google runtime error 4198 but nothing what help me. Error shows up on line with code «wdDoc.SaveAs pdfFileName, wdFormatPDF» but as I said only on work PC or notebook.

Содержание

  1. Thread: Excel Add In runtime error 4198
  2. Excel Add In runtime error 4198
  3. Run time error 4198 vba excel
  4. Answered by:
  5. Question
  6. Answers
  7. All replies
  8. Run time error 4198 vba excel
  9. Лучший отвечающий
  10. Вопрос
  11. Ответы
  12. Все ответы
  13. Run time error 4198 vba excel
  14. Answered by:
  15. Question
  16. Answers
  17. All replies
  18. Run time error 4198 vba excel
  19. Answered by:
  20. Question
  21. Answers
  22. All replies

Thread: Excel Add In runtime error 4198

Thread Tools
Display

Excel Add In runtime error 4198

First off. Sorry for my ignorance of the computer programming world. I am an end user, and have zero programming background. But I am good at understanding things and taking directions, therefore I believe with a little guidance, I may be able to resolve my issue.

For several years, I have been using an excel add-in, entitled ExcelToWord!, written by an author named dlmille. The add-in allows me to create MS Word templates with specified bookmarks, and merge excel spreadsheets into these templates to create MS Word documents.

I have successfully been using it on multiple machines running windows 7, along with MS Office 2007. I finally upgraded some of my equipment, and find that this add-in does not function properly on my new computers. They are running windows 8.1, with the same clean install of MS Office 2007.

The issue occurs when ExcelToWord! attempts to create the dotx document. I keep receiving the run-time error 4198. And my only options are to end or to debug. When I click debug, the follow code is highlighted, and I’m assuming that mean this is where the problem is.

I don’t know if I have provided enough information, or if I have posted this in the correct forum, but any guidance would be greatly appreciated.

Last edited by CallMeMaybe; 10-17-2015 at 07:52 PM .

Источник

Run time error 4198 vba excel

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I have written a function in Excel 2010 using VBA that performs a mail merge in Word 2010 using a CSV file that I generated with data from the Excel workbook.

When I run the code manually, step by step, using F8, everything works fine. When I run the code from the User Form, the code generates error number 4198 stating ‘Command Failed’. The error occurs in line 16.

I have searched several sources, but I cannot find a solution to my problem. What goes wrong?

Answers

Thanks for your reply. I have tried your suggestion and it seems to work! Only change is I used Resume rather than Resume Next.

I have declared two additional variables: iErrCounter and iWait and I have adjusted my Err_Handler as follows:

I have tested a couple of times and the code only runs into the Err_Handler once. So the 1000 DoEvents (appr. 1 second?) apparently do the job.

iPillar | Selfmade Office Fiddler

My best guess would be that it’s a synchronization problem. Word should run synchronously, but recently more and more things in the application seem to be asynchronous — possibly to make Word faster. But that of course makes life «uncomfortable» for the developer as the object model doesn’t really give us any proper way to find out if Word is ready to receive commands.

How about if you use Resume Next instead of Resume Exit_Handler in your Err_hanlder? (And create a counter that you incrememnt each time the error handler is triggered so that you don’t get in an endless loop. When it reaches a certain value, then use Resume Exit_Handler.) Will the line work on the second, third or fourth try?

Cindy Meister, VSTO/Word MVP

Thanks for your reply. I have tried your suggestion and it seems to work! Only change is I used Resume rather than Resume Next.

I have declared two additional variables: iErrCounter and iWait and I have adjusted my Err_Handler as follows:

I have tested a couple of times and the code only runs into the Err_Handler once. So the 1000 DoEvents (appr. 1 second?) apparently do the job.

Источник

Run time error 4198 vba excel

Лучший отвечающий

Вопрос

I have written a function in Excel 2010 using VBA that performs a mail merge in Word 2010 using a CSV file that I generated with data from the Excel workbook.

When I run the code manually, step by step, using F8, everything works fine. When I run the code from the User Form, the code generates error number 4198 stating ‘Command Failed’. The error occurs in line 16.

I have searched several sources, but I cannot find a solution to my problem. What goes wrong?

Ответы

Thanks for your reply. I have tried your suggestion and it seems to work! Only change is I used Resume rather than Resume Next.

I have declared two additional variables: iErrCounter and iWait and I have adjusted my Err_Handler as follows:

I have tested a couple of times and the code only runs into the Err_Handler once. So the 1000 DoEvents (appr. 1 second?) apparently do the job.

iPillar | Selfmade Office Fiddler

Все ответы

My best guess would be that it’s a synchronization problem. Word should run synchronously, but recently more and more things in the application seem to be asynchronous — possibly to make Word faster. But that of course makes life «uncomfortable» for the developer as the object model doesn’t really give us any proper way to find out if Word is ready to receive commands.

How about if you use Resume Next instead of Resume Exit_Handler in your Err_hanlder? (And create a counter that you incrememnt each time the error handler is triggered so that you don’t get in an endless loop. When it reaches a certain value, then use Resume Exit_Handler.) Will the line work on the second, third or fourth try?

Cindy Meister, VSTO/Word MVP

Thanks for your reply. I have tried your suggestion and it seems to work! Only change is I used Resume rather than Resume Next.

I have declared two additional variables: iErrCounter and iWait and I have adjusted my Err_Handler as follows:

I have tested a couple of times and the code only runs into the Err_Handler once. So the 1000 DoEvents (appr. 1 second?) apparently do the job.

Источник

Run time error 4198 vba excel

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I have written a function in Excel 2010 using VBA that performs a mail merge in Word 2010 using a CSV file that I generated with data from the Excel workbook.

When I run the code manually, step by step, using F8, everything works fine. When I run the code from the User Form, the code generates error number 4198 stating ‘Command Failed’. The error occurs in line 16.

I have searched several sources, but I cannot find a solution to my problem. What goes wrong?

Answers

Thanks for your reply. I have tried your suggestion and it seems to work! Only change is I used Resume rather than Resume Next.

I have declared two additional variables: iErrCounter and iWait and I have adjusted my Err_Handler as follows:

I have tested a couple of times and the code only runs into the Err_Handler once. So the 1000 DoEvents (appr. 1 second?) apparently do the job.

iPillar | Selfmade Office Fiddler

My best guess would be that it’s a synchronization problem. Word should run synchronously, but recently more and more things in the application seem to be asynchronous — possibly to make Word faster. But that of course makes life «uncomfortable» for the developer as the object model doesn’t really give us any proper way to find out if Word is ready to receive commands.

How about if you use Resume Next instead of Resume Exit_Handler in your Err_hanlder? (And create a counter that you incrememnt each time the error handler is triggered so that you don’t get in an endless loop. When it reaches a certain value, then use Resume Exit_Handler.) Will the line work on the second, third or fourth try?

Cindy Meister, VSTO/Word MVP

Thanks for your reply. I have tried your suggestion and it seems to work! Only change is I used Resume rather than Resume Next.

I have declared two additional variables: iErrCounter and iWait and I have adjusted my Err_Handler as follows:

I have tested a couple of times and the code only runs into the Err_Handler once. So the 1000 DoEvents (appr. 1 second?) apparently do the job.

Источник

Run time error 4198 vba excel

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I have written a function in Excel 2010 using VBA that performs a mail merge in Word 2010 using a CSV file that I generated with data from the Excel workbook.

When I run the code manually, step by step, using F8, everything works fine. When I run the code from the User Form, the code generates error number 4198 stating ‘Command Failed’. The error occurs in line 16.

I have searched several sources, but I cannot find a solution to my problem. What goes wrong?

Answers

Thanks for your reply. I have tried your suggestion and it seems to work! Only change is I used Resume rather than Resume Next.

I have declared two additional variables: iErrCounter and iWait and I have adjusted my Err_Handler as follows:

I have tested a couple of times and the code only runs into the Err_Handler once. So the 1000 DoEvents (appr. 1 second?) apparently do the job.

iPillar | Selfmade Office Fiddler

My best guess would be that it’s a synchronization problem. Word should run synchronously, but recently more and more things in the application seem to be asynchronous — possibly to make Word faster. But that of course makes life «uncomfortable» for the developer as the object model doesn’t really give us any proper way to find out if Word is ready to receive commands.

How about if you use Resume Next instead of Resume Exit_Handler in your Err_hanlder? (And create a counter that you incrememnt each time the error handler is triggered so that you don’t get in an endless loop. When it reaches a certain value, then use Resume Exit_Handler.) Will the line work on the second, third or fourth try?

Cindy Meister, VSTO/Word MVP

Thanks for your reply. I have tried your suggestion and it seems to work! Only change is I used Resume rather than Resume Next.

I have declared two additional variables: iErrCounter and iWait and I have adjusted my Err_Handler as follows:

I have tested a couple of times and the code only runs into the Err_Handler once. So the 1000 DoEvents (appr. 1 second?) apparently do the job.

Источник


leena beeharry (leena)

Posted: 9/25/2002 9:54 AM

Help,

I keep getting the 4198 runtime error when attempting to run the following code. I’ve no idea why. :(
I would be grateful for any help;

thanks in advance

Leena

/*********** CODE ***********************/

Private Sub Document_Open()

        Dim prop As String
    Open «C:Speed2001Installation.Properties» For Input As #1
    While Not EOF(1)
        Line Input #1, prop
        If Left(prop, 24) = «INSTALLATION_LOC_REPORTS» Then
            location = Mid(prop, 28)
        End If
    Wend
    Close #1

    ‘select the entire document so that bookmarks can be found and table of contents generated later
    Selection.WholeStory
    Selection.Fields.Update
    Selection.HomeKey Unit:=wdStory

         ‘InsertSpreadsheets

                 ‘Move to the top of the doc before saving..
    Selection.HomeKey Unit:=wdStory

         saveAsLocation = location + «datarapidreports» & «mnds»

        ‘Save the document to the users default word folder..
    ActiveDocument.SaveAs fileName:=saveAsLocation, _
    FileFormat:=wdFormatDocument, LockComments:=False, Password:=»», AddToRecentFiles:=True, _
    WritePassword:=»», ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False

      End Sub

/************** END OF CODE *******************/

  • | Post Points: 35
Icon Ex Номер ошибки: Ошибка 4198
Название ошибки: Microsoft Word Error 4198
Описание ошибки: Ошибка 4198: Возникла ошибка в приложении Microsoft Word. Приложение будет закрыто. Приносим извинения за неудобства.
Разработчик: Microsoft Corporation
Программное обеспечение: Microsoft Word
Относится к: Windows XP, Vista, 7, 8, 10, 11

Обзор «Microsoft Word Error 4198»

«Microsoft Word Error 4198» также считается ошибкой во время выполнения (ошибкой). Разработчики программного обеспечения пытаются обеспечить, чтобы программное обеспечение было свободным от этих сбоев, пока оно не будет публично выпущено. К сожалению, инженеры являются людьми и часто могут делать ошибки во время тестирования, отсутствует ошибка 4198.

Пользователи Microsoft Word могут столкнуться с ошибкой 4198, вызванной нормальным использованием приложения, которое также может читать как «Microsoft Word Error 4198». Во время возникновения ошибки 4198 конечный пользователь может сообщить о проблеме в Microsoft Corporation. Затем Microsoft Corporation нужно будет исправить эти ошибки в главном исходном коде и предоставить модифицированную версию для загрузки. Эта ситуация происходит из-за обновления программного обеспечения Microsoft Word является одним из решений ошибок 4198 ошибок и других проблем.

Сбой во время запуска Microsoft Word или во время выполнения, как правило, когда вы столкнетесь с «Microsoft Word Error 4198». Вот три наиболее заметные причины ошибки ошибки 4198 во время выполнения происходят:

Ошибка 4198 Crash — Ошибка 4198 является хорошо известной, которая происходит, когда неправильная строка кода компилируется в исходный код программы. Обычно это происходит, когда Microsoft Word не может распознать, что ему дается неправильный ввод, или не знает, что он должен производить.

Утечка памяти «Microsoft Word Error 4198» — когда происходит утечка памяти Microsoft Word, это приведет к вялой работе операционной системы из-за нехватки системных ресурсов. Повреждение памяти и другие потенциальные ошибки в коде могут произойти, когда память обрабатывается неправильно.

Ошибка 4198 Logic Error — Логическая ошибка вызывает неправильный вывод, даже если пользователь дал действительные входные данные. Виновником в этом случае обычно является недостаток в исходном коде Microsoft Corporation, который неправильно обрабатывает ввод.

Microsoft Word Error 4198 проблемы часто являются результатом отсутствия, удаления или случайного перемещения файла из исходного места установки Microsoft Word. Большую часть проблем, связанных с данными файлами, можно решить посредством скачивания и установки последней версии файла Microsoft Corporation. В качестве дополнительного шага по устранению неполадок мы настоятельно рекомендуем очистить все пути к неверным файлам и ссылки на расширения файлов Microsoft Corporation, которые могут способствовать возникновению такого рода ошибок, связанных с Microsoft Word Error 4198.

Распространенные проблемы Microsoft Word Error 4198

Частичный список ошибок Microsoft Word Error 4198 Microsoft Word:

  • «Ошибка программного обеспечения Microsoft Word Error 4198. «
  • «Microsoft Word Error 4198 не является приложением Win32.»
  • «Microsoft Word Error 4198 должен быть закрыт. «
  • «К сожалению, мы не можем найти Microsoft Word Error 4198. «
  • «Microsoft Word Error 4198 не может быть найден. «
  • «Ошибка запуска программы: Microsoft Word Error 4198.»
  • «Microsoft Word Error 4198 не выполняется. «
  • «Microsoft Word Error 4198 выйти. «
  • «Microsoft Word Error 4198: путь приложения является ошибкой. «

Обычно ошибки Microsoft Word Error 4198 с Microsoft Word возникают во время запуска или завершения работы, в то время как программы, связанные с Microsoft Word Error 4198, выполняются, или редко во время последовательности обновления ОС. Отслеживание того, когда и где возникает ошибка Microsoft Word Error 4198, является важной информацией при устранении проблемы.

Причины проблем Microsoft Word Error 4198

Проблемы Microsoft Word Error 4198 могут быть отнесены к поврежденным или отсутствующим файлам, содержащим ошибки записям реестра, связанным с Microsoft Word Error 4198, или к вирусам / вредоносному ПО.

Точнее, ошибки Microsoft Word Error 4198, созданные из:

  • Недопустимый Microsoft Word Error 4198 или поврежденный раздел реестра.
  • Вредоносные программы заразили Microsoft Word Error 4198, создавая повреждение.
  • Вредоносное удаление (или ошибка) Microsoft Word Error 4198 другим приложением (не Microsoft Word).
  • Другое приложение, конфликтующее с Microsoft Word Error 4198 или другими общими ссылками.
  • Поврежденная установка или загрузка Microsoft Word (Microsoft Word Error 4198).

Продукт Solvusoft

Загрузка
WinThruster 2022 — Проверьте свой компьютер на наличие ошибок.

Совместима с Windows 2000, XP, Vista, 7, 8, 10 и 11

Установить необязательные продукты — WinThruster (Solvusoft) | Лицензия | Политика защиты личных сведений | Условия | Удаление

Понравилась статья? Поделить с друзьями:
  • Rpg 2000 ошибка
  • Runtime error 40 229 ошибка
  • Rpcs3 ошибка при запуске приложения 0xc000007b
  • Runtime 140 ошибка
  • Runtime error 3146 odbc ошибка вызова