Word runtime error 4248

Explains how some run-time error messages may occur when you change the properties of a document by using VBA in Word 2003 or Word 2007. You may experience the errors when you the document is unopened.

Symptoms

When you try to use Microsoft Visual Basic for Applications (VBA) to change the properties of a document, you may receive one of the following error messages:

Run-time error ‘4248’:

This command is not available because no document is open.

Run-time error ‘4605’:
This method or property is not available because a document window is not active.

Run-time error ‘5941’:
The requested member of the collection does not exist.

Cause

This problem may occur if you do not have a document open, or if the document that you are referencing is not open. Word can only change the properties of an open (or visible) document.

Note These error messages may also appear if you open the document with the Visible property set to
False.

Workaround

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners — https://partner.microsoft.com/global/30000104

Microsoft Advisory Services — http://support.microsoft.com/gp/advisoryservice

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
For additional information about how to use the sample code that is included in this article, click the following article number to view the article in the Microsoft Knowledge Base:

290140 OFFXP: How to Run Sample Code from Knowledge Base Articles

The following sample VBA macros demonstrate how to change the value of the Title field in the
Properties dialog box. The following sample also includes code to trap the error, in case there are no documents open, and to display a message:

Sub ChangeDocProperties()

On Error GoTo ErrHandler
ActiveDocument.BuiltInDocumentProperties("Title") = "My Title"
Exit Sub

ErrHandler:
If Err <> 0 Then
'
' Display an error message.
'
MsgBox Err.Description
'
' Clear the error.
'
Err.Clear
Resume Next

End If

End Sub

The following sample macro includes code that will do the following:

  • Trap the error, in case there are no documents open.

  • In the error trap, create a new document.

  • Resume execution at the line that caused the error.

Sub ChangeDocProperties()

On Error GoTo ErrHandler
ActiveDocument.BuiltInDocumentProperties("Title") = "My Title"
Exit Sub

ErrHandler:
If Err <> 0 Then
'
' Add a document.
'
Documents.Add
'
' Clear the error.
'
Err.Clear
'
' Run the code that caused the error.
'
Resume

End If

End Sub

References

For additional information about how to get help with VBA, click the following article number to view the article in the Microsoft Knowledge Base:

305326 OFFXP: Programming Resources for Visual Basic for Applications

Need more help?

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

«Microsoft Word Error 4248» Введение

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

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

Когда происходит ошибка 4248?

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

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

Утечка памяти «Microsoft Word Error 4248» — последствия утечки памяти Microsoft Word связаны с неисправной операционной системой. Возможные причины включают сбой Microsoft Corporation для девыделения памяти в программе или когда плохой код выполняет «бесконечный цикл».

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

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

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

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

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

Ошибки Microsoft Word Error 4248 EXE возникают во время установки Microsoft Word, при запуске приложений, связанных с Microsoft Word Error 4248 (Microsoft Word), во время запуска или завершения работы или во время установки ОС Windows. Важно отметить, когда возникают проблемы Microsoft Word Error 4248, так как это помогает устранять проблемы Microsoft Word (и сообщать в Microsoft Corporation).

Эпицентры Microsoft Word Error 4248 Головные боли

Проблемы Microsoft Word Error 4248 вызваны поврежденным или отсутствующим Microsoft Word Error 4248, недопустимыми ключами реестра, связанными с Microsoft Word, или вредоносным ПО.

Более конкретно, данные ошибки Microsoft Word Error 4248 могут быть вызваны следующими причинами:

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

Продукт Solvusoft

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

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

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

How to fix the Runtime Code 4248 Microsoft Word Error 4248

This article features error number Code 4248, commonly known as Microsoft Word Error 4248 described as Error 4248: Microsoft Word has encountered a problem and needs to close. We are sorry for the inconvenience.

About Runtime Code 4248

Runtime Code 4248 happens when Microsoft Word fails or crashes whilst it’s running, hence its name. It doesn’t necessarily mean that the code was corrupt in some way, but just that it did not work during its run-time. This kind of error will appear as an annoying notification on your screen unless handled and corrected. Here are symptoms, causes and ways to troubleshoot the problem.

Definitions (Beta)

Here we list some definitions for the words contained in your error, in an attempt to help you understand your problem. This is a work in progress, so sometimes we might define the word incorrectly, so feel free to skip this section!

  • Microsoft word — For programming questions related to Microsoft’s «Word» editor

Symptoms of Code 4248 — Microsoft Word Error 4248

Runtime errors happen without warning. The error message can come up the screen anytime Microsoft Word is run. In fact, the error message or some other dialogue box can come up again and again if not addressed early on.

There may be instances of files deletion or new files appearing. Though this symptom is largely due to virus infection, it can be attributed as a symptom for runtime error, as virus infection is one of the causes for runtime error. User may also experience a sudden drop in internet connection speed, yet again, this is not always the case.

Fix Microsoft Word Error 4248 (Error Code 4248)
(For illustrative purposes only)

Causes of Microsoft Word Error 4248 — Code 4248

During software design, programmers code anticipating the occurrence of errors. However, there are no perfect designs, as errors can be expected even with the best program design. Glitches can happen during runtime if a certain error is not experienced and addressed during design and testing.

Runtime errors are generally caused by incompatible programs running at the same time. It may also occur because of memory problem, a bad graphics driver or virus infection. Whatever the case may be, the problem must be resolved immediately to avoid further problems. Here are ways to remedy the error.

Repair Methods

Runtime errors may be annoying and persistent, but it is not totally hopeless, repairs are available. Here are ways to do it.

If a repair method works for you, please click the upvote button to the left of the answer, this will let other users know which repair method is currently working the best.

Please note: Neither ErrorVault.com nor it’s writers claim responsibility for the results of the actions taken from employing any of the repair methods listed on this page — you complete these steps at your own risk.

Method 1 — Close Conflicting Programs

When you get a runtime error, keep in mind that it is happening due to programs that are conflicting with each other. The first thing you can do to resolve the problem is to stop these conflicting programs.

  • Open Task Manager by clicking Ctrl-Alt-Del at the same time. This will let you see the list of programs currently running.
  • Go to the Processes tab and stop the programs one by one by highlighting each program and clicking the End Process buttom.
  • You will need to observe if the error message will reoccur each time you stop a process.
  • Once you get to identify which program is causing the error, you may go ahead with the next troubleshooting step, reinstalling the application.

Method 2 — Update / Reinstall Conflicting Programs

Using Control Panel

  • For Windows 7, click the Start Button, then click Control panel, then Uninstall a program
  • For Windows 8, click the Start Button, then scroll down and click More Settings, then click Control panel > Uninstall a program.
  • For Windows 10, just type Control Panel on the search box and click the result, then click Uninstall a program
  • Once inside Programs and Features, click the problem program and click Update or Uninstall.
  • If you chose to update, then you will just need to follow the prompt to complete the process, however if you chose to Uninstall, you will follow the prompt to uninstall and then re-download or use the application’s installation disk to reinstall the program.

Using Other Methods

  • For Windows 7, you may find the list of all installed programs when you click Start and scroll your mouse over the list that appear on the tab. You may see on that list utility for uninstalling the program. You may go ahead and uninstall using utilities available in this tab.
  • For Windows 10, you may click Start, then Settings, then choose Apps.
  • Scroll down to see the list of Apps and features installed in your computer.
  • Click the Program which is causing the runtime error, then you may choose to uninstall or click Advanced options to reset the application.

Method 3 — Update your Virus protection program or download and install the latest Windows Update

Virus infection causing runtime error on your computer must immediately be prevented, quarantined or deleted. Make sure you update your virus program and run a thorough scan of the computer or, run Windows update so you can get the latest virus definition and fix.

Method 4 — Re-install Runtime Libraries

You might be getting the error because of an update, like the MS Visual C++ package which might not be installed properly or completely. What you can do then is to uninstall the current package and install a fresh copy.

  • Uninstall the package by going to Programs and Features, find and highlight the Microsoft Visual C++ Redistributable Package.
  • Click Uninstall on top of the list, and when it is done, reboot your computer.
  • Download the latest redistributable package from Microsoft then install it.

Method 5 — Run Disk Cleanup

You might also be experiencing runtime error because of a very low free space on your computer.

  • You should consider backing up your files and freeing up space on your hard drive
  • You can also clear your cache and reboot your computer
  • You can also run Disk Cleanup, open your explorer window and right click your main directory (this is usually C: )
  • Click Properties and then click Disk Cleanup

Method 6 — Reinstall Your Graphics Driver

If the error is related to a bad graphics driver, then you may do the following:

  • Open your Device Manager, locate the graphics driver
  • Right click the video card driver then click uninstall, then restart your computer

Method 7 — IE related Runtime Error

If the error you are getting is related to the Internet Explorer, you may do the following:

  1. Reset your browser.
    • For Windows 7, you may click Start, go to Control Panel, then click Internet Options on the left side. Then you can click Advanced tab then click the Reset button.
    • For Windows 8 and 10, you may click search and type Internet Options, then go to Advanced tab and click Reset.
  2. Disable script debugging and error notifications.
    • On the same Internet Options window, you may go to Advanced tab and look for Disable script debugging
    • Put a check mark on the radio button
    • At the same time, uncheck the «Display a Notification about every Script Error» item and then click Apply and OK, then reboot your computer.

If these quick fixes do not work, you can always backup files and run repair reinstall on your computer. However, you can do that later when the solutions listed here did not do the job.

Other languages:

Wie beheben Fehler 4248 (Microsoft Word-Fehler 4248) — Fehler 4248: Microsoft Word hat ein Problem festgestellt und muss geschlossen werden. Wir entschuldigen uns für die Unannehmlichkeiten.
Come fissare Errore 4248 (Errore di Microsoft Word 4248) — Errore 4248: Microsoft Word ha riscontrato un problema e deve essere chiuso. Ci scusiamo per l’inconveniente.
Hoe maak je Fout 4248 (Microsoft Word-fout 4248) — Fout 4248: Microsoft Word heeft een probleem ondervonden en moet worden afgesloten. Excuses voor het ongemak.
Comment réparer Erreur 4248 (Erreur Microsoft Word 4248) — Erreur 4248 : Microsoft Word a rencontré un problème et doit se fermer. Nous sommes désolés du dérangement.
어떻게 고치는 지 오류 4248 (마이크로소프트 워드 오류 4248) — 오류 4248: Microsoft Word에 문제가 발생해 닫아야 합니다. 불편을 드려 죄송합니다.
Como corrigir o Erro 4248 (Erro 4248 do Microsoft Word) — Erro 4248: O Microsoft Word encontrou um problema e precisa fechar. Lamentamos o inconveniente.
Hur man åtgärdar Fel 4248 (Microsoft Word-fel 4248) — Fel 4248: Microsoft Word har stött på ett problem och måste avslutas. Vi är ledsna för besväret.
Как исправить Ошибка 4248 (Ошибка Microsoft Word 4248) — Ошибка 4248: Возникла ошибка в приложении Microsoft Word. Приложение будет закрыто. Приносим свои извинения за неудобства.
Jak naprawić Błąd 4248 (Błąd Microsoft Word 4248) — Błąd 4248: Microsoft Word napotkał problem i musi zostać zamknięty. Przepraszamy za niedogodności.
Cómo arreglar Error 4248 (Error 4248 de Microsoft Word) — Error 4248: Microsoft Word ha detectado un problema y debe cerrarse. Lamentamos las molestias.

The Author About The Author: Phil Hart has been a Microsoft Community Contributor since 2010. With a current point score over 100,000, they’ve contributed more than 3000 answers in the Microsoft Support forums and have created almost 200 new help articles in the Technet Wiki.

Follow Us: Facebook Youtube Twitter

Recommended Repair Tool:

This repair tool can fix common computer problems such as blue screens, crashes and freezes, missing DLL files, as well as repair malware/virus damage and more by replacing damaged and missing system files.

STEP 1:

Click Here to Download and install the Windows repair tool.

STEP 2:

Click on Start Scan and let it analyze your device.

STEP 3:

Click on Repair All to fix all of the issues it detected.

DOWNLOAD NOW

Compatibility

Requirements

1 Ghz CPU, 512 MB RAM, 40 GB HDD
This download offers unlimited scans of your Windows PC for free. Full system repairs start at $19.95.

Article ID: ACX08339EN

Applies To: Windows 10, Windows 8.1, Windows 7, Windows Vista, Windows XP, Windows 2000

Speed Up Tip #13

Removing Unwanted Pre-Installed Software:

The unwanted software, aka junk software or bloatware, that came pre-installed with your computer can be easily removed using PC Decrapifier. It is a free and easy-to-use program that can help you speed up your new pc and save you hours of uninstalling those bloatwares manually.

Click Here for another way to speed up your Windows PC

  1. 04-04-2012, 01:45 PM


    #1

    Run-time error ‘4248’: this command is not available because no document is open

    Hello my document is attached. I keep getting this error on Windows XP SP3

    behavior is like this:

    4248 referenced in title block above.If I click “End” on the error window, the macros ran. They didn’t work right, though, because the boxes didn’t check.If I choose Debug, then the Visual Basic page shows up and highlights the first half-line of the programing. Any ideas? Thanks, Midani[vba]Private Sub Document_Open()
    If ActiveDocument.FormFields(«text64»).Result = «Yes» Then ActiveDocument.FormFields(«Check1»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text64»).Result = «No» Then ActiveDocument.FormFields(«Check2»).CheckBox.Value = True[/vba]
    [vba]
    If ActiveDocument.FormFields(«text65»).Result = «Inpatient» Then ActiveDocument.FormFields(«Check3»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «ER/Outpatient» Then ActiveDocument.FormFields(«Check4»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «DOA» Then ActiveDocument.FormFields(«Check5»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «Nursing Home» Then ActiveDocument.FormFields(«Check6»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «Hospice» Then ActiveDocument.FormFields(«Check7»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «Residence» Then ActiveDocument.FormFields(«Check8»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «Other (Specify)» Then ActiveDocument.FormFields(«Check9»).CheckBox.Value = True

    If ActiveDocument.FormFields(«text66»).Result = «Married» Then ActiveDocument.FormFields(«Check10»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text66»).Result = «Never Married» Then ActiveDocument.FormFields(«Check11»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text66»).Result = «Widowed» Then ActiveDocument.FormFields(«Check12»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text66»).Result = «Divorced» Then ActiveDocument.FormFields(«Check13»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text66»).Result = «Unknown» Then ActiveDocument.FormFields(«Check14»).CheckBox.Value = True

    If ActiveDocument.FormFields(«text67»).Result = «Yes» Then ActiveDocument.FormFields(«Check15»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text67»).Result = «No» Then ActiveDocument.FormFields(«Check16»).CheckBox.Value = True

    If ActiveDocument.FormFields(«text68»).Result = «No» Then ActiveDocument.FormFields(«Check17»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text68»).Result = «Yes» Then ActiveDocument.FormFields(«Check18»).CheckBox.Value = True

    If ActiveDocument.FormFields(«text69»).Result = «Resomation» Then ActiveDocument.FormFields(«Check19»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Burial» Then ActiveDocument.FormFields(«Check20»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Cremation» Then ActiveDocument.FormFields(«Check21»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Removal from State» Then ActiveDocument.FormFields(«Check22»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Donation» Then ActiveDocument.FormFields(«Check23»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Other (Specify)» Then ActiveDocument.FormFields(«Check24»).CheckBox.Value = True

    ActiveDocument.FormFields(«text64″).Result = » «
    ActiveDocument.FormFields(«text65″).Result = » «
    ActiveDocument.FormFields(«text66″).Result = » «
    ActiveDocument.FormFields(«text67″).Result = » «
    ActiveDocument.FormFields(«text68″).Result = » «
    ActiveDocument.FormFields(«text69″).Result = » «
    End Sub

    Sub ChangeDocProperties()
    On Error GoTo ErrHandler
    ActiveDocument.BuiltInDocumentProperties(«Title») = «DC (Burial)»
    Exit Sub

    ErrHandler:
    If Err <> 0 Then

    ‘Add a document.
    Documents.Add

    ‘Clear the error.
    Err.Clear

    ‘Execute the code that caused the error.
    Resume

    End If
    End Sub
    Sub CountHiddenDocs()
    ‘ This macro opens an existing document as hidden
    ‘ then makes the hidden document visible.
    Dim Doc1 As Document

    ‘ Open MyDoc.Doc document as hidden.
    Set Doc1 = Documents.Open(«<Path>MyDoc.Doc», Visible:=False)

    ‘ Reset the document object variable to make visible the
    ‘ hidden document.

    ‘ NOTE: The following command line will NOT open a
    ‘ second instance of the hidden document but instead
    ‘ make the currently open, hidden instance of the
    ‘ document visible.
    Set Doc1 = Documents.Open(«<Path>MyDoc.Doc», Visible:=True)
    Doc1.ActiveWindow.Activate
    End Sub


    [/vba]


  2. 04-04-2012, 02:57 PM


    #2

    We need more information. What module is the code in?

    Document_Open must be in the document itself. Clearly if you are getting that error SOMETHING is not right. Please describe the actual conditions.

    BTW: you should use Select Case rather than multiple IF statements.

    In your code what happens if text65 = Inpatient?

    1. Check3 = true
    2. If statement executes, testing if text65 = ER/Outpatient
    3. If statement executes, testing if text65 = DOA
    4. If statement executes, testing if text65 = Nursing Home
    5. If statement executes, testing if text65 = Hospice
    6. If statement executes, testing if text65 = Residence
    7. If statement executes, testing if text65 = Other (Specify)

    If you use Select Case, what happens if text65 = Inpatient?

    [vba]
    Select Case ActiveDocument.FormFields(«text65»).Result
    Case «Inpatient»
    ActiveDocument.FormFields(«Check3»).CheckBox.Value = True
    Case «ER/Outpatient»
    ActiveDocument.FormFields(«Check4»).CheckBox.Value = True
    Case «DOA»
    ActiveDocument.FormFields(«Check5»).CheckBox.Value = True
    Case «Nursing Home»
    ActiveDocument.FormFields(«Check6»).CheckBox.Value = True
    Case «Hospice»
    ActiveDocument.FormFields(«Check7»).CheckBox.Value = True
    Case «Residence»
    ActiveDocument.FormFields(«Check8»).CheckBox.Value = True
    End Select[/vba]

    1. Check3 = True

    …and that is it. Nothing else happens. The other conditions are not tested – this is what Select Case is for — testing multiple values of the SAME variable or object.


  3. 04-05-2012, 02:51 PM


    #3

    Hello this code that I displayed is the code corresponding to the VBA document itself. Would it help if I zipped up the document and sent it to you for your review? I have to say that I am a Java application developer and
    I know very little about VB or much less VBA.

    I am simply trying to overcome that error when the document is opened up on a Microsoft Professional XP SP3 machine.

    There are many other documents like it but I did not code it. I did review everything that Microsoft said on the subject but it was not helpful.

    If you could re-explain what you were saying to me because I am such a newbie. I noted that you produced some code with the Option Explicit but I am not sure what you meant by it.

    Thanks a lot, Midani


  4. 04-05-2012, 04:18 PM


    #4

    Maybe you need to stat using Help. Especially Option Explicit. Put your cursor on it and press F1.

    Ditto Select Case, although that is a very basic programming concept.

    I will ask again…please describe the exact circumstances. It will also help if you posted your entire code. What is the full code for the procedure with:
    [vba]If ActiveDocument.FormFields(«text65»).Result = «Inpatient» Then _
    ActiveDocument.FormFields(«Check3»).CheckBox.Value = True [/vba]


  5. 04-05-2012, 04:18 PM


    #5

    Maybe you need to stat using Help. Especially Option Explicit. Put your cursor on it and press F1.

    Ditto Select Case, although that is a very basic programming concept.

    I will ask again…please describe the exact circumstances. It will also help if you posted your entire code. What is the full code for the procedure with:
    [vba]If ActiveDocument.FormFields(«text65»).Result = «Inpatient» Then _
    ActiveDocument.FormFields(«Check3»).CheckBox.Value = True [/vba]


  6. 04-05-2012, 04:18 PM


    #6

    Maybe you need to start using Help. Especially Option Explicit. Put your cursor on it and press F1.

    Ditto Select Case, although that is a very basic programming concept.

    I will ask again…please describe the exact circumstances. It will also help if you posted your entire code. What is the full code for the procedure with:
    [vba]If ActiveDocument.FormFields(«text65»).Result = «Inpatient» Then _
    ActiveDocument.FormFields(«Check3»).CheckBox.Value = True [/vba]


  7. 04-09-2012, 07:08 AM


    #7

    The full code for the entire document is here, it is for the General Module and the Open Module.

    I went ahead and put all the events into a notepad for you:

    [VBA]
    Private Sub Document_Close()
    End Sub
    Private Sub Document_ContentControlAfterAdd(ByVal NewContentControl As ContentControl, ByVal InUndoRedo As Boolean)
    End Sub
    Private Sub Document_ContentControlBeforeContentUpdate(ByVal ContentControl As ContentControl, Content As String)
    End Sub
    Private Sub Document_ContentControlBeforeDelete(ByVal OldContentControl As ContentControl, ByVal InUndoRedo As Boolean)
    End Sub
    Private Sub Document_ContentControlBeforeStoreUpdate(ByVal ContentControl As ContentControl, Content As String)
    End Sub
    Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)
    End Sub
    Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
    End Sub
    Private Sub Document_Open()
    If ActiveDocument.FormFields(«text64»).Result = «Yes» Then ActiveDocument.FormFields(«Check1»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text64»).Result = «No» Then ActiveDocument.FormFields(«Check2»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «Inpatient» Then ActiveDocument.FormFields(«Check3»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «ER/Outpatient» Then ActiveDocument.FormFields(«Check4»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «DOA» Then ActiveDocument.FormFields(«Check5»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «Nursing Home» Then ActiveDocument.FormFields(«Check6»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «Hospice» Then ActiveDocument.FormFields(«Check7»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «Residence» Then ActiveDocument.FormFields(«Check8»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text65»).Result = «Other (Specify)» Then ActiveDocument.FormFields(«Check9»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text66»).Result = «Married» Then ActiveDocument.FormFields(«Check10»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text66»).Result = «Never Married» Then ActiveDocument.FormFields(«Check11»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text66»).Result = «Widowed» Then ActiveDocument.FormFields(«Check12»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text66»).Result = «Divorced» Then ActiveDocument.FormFields(«Check13»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text66»).Result = «Unknown» Then ActiveDocument.FormFields(«Check14»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text67»).Result = «Yes» Then ActiveDocument.FormFields(«Check15»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text67»).Result = «No» Then ActiveDocument.FormFields(«Check16»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text68»).Result = «No» Then ActiveDocument.FormFields(«Check17»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text68»).Result = «Yes» Then ActiveDocument.FormFields(«Check18»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Resomation» Then ActiveDocument.FormFields(«Check19»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Burial» Then ActiveDocument.FormFields(«Check20»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Cremation» Then ActiveDocument.FormFields(«Check21»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Removal from State» Then ActiveDocument.FormFields(«Check22»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Donation» Then ActiveDocument.FormFields(«Check23»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text69»).Result = «Other (Specify)» Then ActiveDocument.FormFields(«Check24»).CheckBox.Value = True
    ActiveDocument.FormFields(«text64″).Result = » «
    ActiveDocument.FormFields(«text65″).Result = » «
    ActiveDocument.FormFields(«text66″).Result = » «
    ActiveDocument.FormFields(«text67″).Result = » «
    ActiveDocument.FormFields(«text68″).Result = » «
    ActiveDocument.FormFields(«text69″).Result = » «
    End Sub
    ‘Sub ChangeDocProperties()
    ‘ On Error GoTo ErrHandler
    ‘ ActiveDocument.BuiltInDocumentProperties(«Title») = «DC (Burial)»
    ‘Exit Sub
    ‘ErrHandler:
    ‘ If Err <> 0 Then
    ‘Add a document.
    ‘ Documents.Add
    ‘Clear the error.
    ‘ Err.Clear
    ‘Execute the code that caused the error.
    ‘ Resume
    ‘ End If
    ‘End Sub
    ‘Sub CountHiddenDocs()
    ‘ This macro opens an existing document as hidden
    ‘ then makes the hidden document visible.
    ‘ Dim Doc1 As Document
    ‘ Open MyDoc.Doc document as hidden.
    ‘ Set Doc1 = Documents.Open(«MyDoc.Doc», Visible:=False)
    ‘ Reset the document object variable to make visible the
    ‘ hidden document.

    ‘ NOTE: The following command line will NOT open a
    ‘ second instance of the hidden document but instead
    ‘ make the currently open, hidden instance of the
    ‘ document visible.
    ‘Set Doc1 = Documents.Open(«<Path>MyDoc.Doc», Visible:=True)
    ‘Doc1.ActiveWindow.Activate
    ‘End Sub

    Private Sub Document_Sync(ByVal SyncEventType As Office.MsoSyncEventType)
    End Sub
    Private Sub Document_XMLAfterInsert(ByVal NewXMLNode As XMLNode, ByVal InUndoRedo As Boolean)
    End Sub
    Private Sub Document_XMLBeforeDelete(ByVal DeletedRange As Range, ByVal OldXMLNode As XMLNode, ByVal InUndoRedo As Boolean)
    End Sub
    [/VBA]


  8. 04-09-2012, 07:24 AM


    #8

    I changed my code for the Document module:

    [VBA]Private Sub Document_Open()
    If ActiveDocument.FormFields(«text64»).Result = «Yes» Then ActiveDocument.FormFields(«Check1»).CheckBox.Value = True
    If ActiveDocument.FormFields(«text64»).Result = «No» Then ActiveDocument.FormFields(«Check2»).CheckBox.Value = True
    Select Case ActiveDocument.FormFields(«text65»).Result
    Case «Inpatient»
    ActiveDocument.FormFields(«Check3»).CheckBox.Value = True
    Case «ER/Outpatient»
    ActiveDocument.FormFields(«Check4»).CheckBox.Value = True
    Case «DOA»
    ActiveDocument.FormFields(«Check5»).CheckBox.Value = True
    Case «Nursing Home»
    ActiveDocument.FormFields(«Check6»).CheckBox.Value = True
    Case «Hospice»
    ActiveDocument.FormFields(«Check7»).CheckBox.Value = True
    Case «Residence»
    ActiveDocument.FormFields(«Check8»).CheckBox.Value = True
    Case «Other»
    ActiveDocument.FormFields(«Check9»).CheckBox.Value = True
    End Select
    Select Case ActiveDocument.FormFields(«text66»).Result
    Case «Married»
    ActiveDocument.FormFields(«Check10»).CheckBox.Value = True
    Case «Never Married»
    ActiveDocument.FormFields(«Check11»).CheckBox.Value = True
    Case «Widowed»
    ActiveDocument.FormFields(«Check12»).CheckBox.Value = True
    Case «Divorced»
    ActiveDocument.FormFields(«Check13»).CheckBox.Value = True
    Case «Unknown»
    ActiveDocument.FormFields(«Check14»).CheckBox.Value = True
    End Select
    Select Case ActiveDocument.FormFields(«text67»).Result
    Case «Yes»
    ActiveDocument.FormFields(«Check15»).CheckBox.Value = True
    Case «No»
    ActiveDocument.FormFields(«Check16»).CheckBox.Value = True
    End Select

    Select Case ActiveDocument.FormFields(«text68»).Result
    Case «No»
    ActiveDocument.FormFields(«Check17»).CheckBox.Value = True
    Case «Yes»
    ActiveDocument.FormFields(«Check18»).CheckBox.Value = True
    End Select

    Select Case ActiveDocument.FormFields(«text69»).Result
    Case «Resomation»
    ActiveDocument.FormFields(«Check19»).CheckBox.Value = True
    Case «Burial»
    ActiveDocument.FormFields(«Check20»).CheckBox.Value = True
    Case «Cremation»
    ActiveDocument.FormFields(«Check21»).CheckBox.Value = True
    Case «Removal from State»
    ActiveDocument.FormFields(«Check22»).CheckBox.Value = True
    Case «Donation»
    ActiveDocument.FormFields(«Check23»).CheckBox.Value = True
    Case «Other (Specify)»
    ActiveDocument.FormFields(«Check24»).CheckBox.Value = True
    End Select
    ActiveDocument.FormFields(«text64″).Result = » «
    ActiveDocument.FormFields(«text65″).Result = » «
    ActiveDocument.FormFields(«text66″).Result = » «
    ActiveDocument.FormFields(«text67″).Result = » «
    ActiveDocument.FormFields(«text68″).Result = » «
    ActiveDocument.FormFields(«text69″).Result = » «
    End Sub[/VBA]


  9. 04-09-2012, 08:02 AM


    #9


  10. 04-09-2012, 11:23 AM


    #10

    When I open that document I do not get the error you say you get.

    I can not check if the the results are correct as you do not use explicit naming…and I sure am not going to go through the entire document trying to find which formfield is «text65», or even which checkbox is Check1,


  11. 04-09-2012, 12:21 PM


    #11

    Ok thanks and sorry to be so frustrating.

    You asked earlier:

    In your code what happens if text65 = Inpatient?

    Then the box gets checked that says : Inpatient.

    I am checking on the meaning of the other fields you mention.

    Do you have any suggestions on how to Explicitly name those other fields, could you provide an example perhaps? Thanks, Midani


  12. 04-09-2012, 12:51 PM


    #12

    I found out that there are six (6) fields on the bottom of the form that relate to the following:
    64 Case Military
    65 Case Place of Death
    66 Case Marital Status
    67 Case Resident City Limits
    68 Case Hispanic Origin
    69 Case Dispositions

    The way that it is supposed to work is that there is a parameter from XML which gets passed to the form from those six (6) fields which tells the form which checkboxes get checked. After it executes this, it also disappears from view.


  13. 04-09-2012, 02:39 PM


    #13

    «The way that it is supposed to work is that there is a parameter from XML which gets passed to the form from those six (6) fields which tells the form which checkboxes get checked. After it executes this, it also disappears from view.»

    What this got to do with your original posted question?

    Run-time error ‘4248’: this command is not available because no document is open

    Explicitly named controls (the formfields) means just that. The formfield is NAMED somethng meaningful. The name is set in the Properties dialog.

    For example (and yes I could go through the document trying to find the right one), you have text64 make Check1 checked or unchecked. BUT, which one is it? I do not even know — and I have been looking for 5 minutes -which formfield is text64.


  14. 04-10-2012, 06:41 AM


    #14

    Answer

    It is in the lower left corner in a table by itself of the form, below the actual form itself, it is hidden.

    Thanks,
    Midani


  15. 04-10-2012, 10:17 AM


    #15

    That was just an example. I do not actually care where it is. The point is that text64 does not MEAN anything. The name is meaningless, it does not give any information about where it is, nor any meaningful/logical connection to Check1 (which is where exactly). In other words, I have NO easy way of verifying that the value of text64 is in fact making the correct value in the checkbox — as I do not have any easy way of finding them.

    But back to why you posted. There is no error 4248. So what exactly is your problem?


  16. 04-11-2012, 11:12 AM


    #16

    I looking at the code for some time. (whoever set this up should really look into object naming standards.)

    Error 4248 is self explanatory, but I’m wondering it this occurs after a new document is added with the Sub ChangeDocProperties?

    Can you describe the steps to using this document? How do the formfields at the bottom get updated?

    Last edited by Tinbendr; 04-11-2012 at 11:27 AM.


  17. 04-11-2012, 11:28 AM


    #17

    Answer Regarding The Uses of this document

    Hello I am so glad you commented, VBA is out of my realm and I need so much help on this one.

    What happens is that there is a little table on the lower left hand side of the page, and what happens is that there are six (6) values that get passed to the document from a sister document in xml (words) and these words would execute checkboxes ordinarily. These are fields 64-69.

    The word which passes as field 64 to the form informs the checkboxes to be checked.

    EXAMPLE: If the person did military service under item 6 of the form, field name 64 could have two cases a yes or a no, and a yes would pass to the form and also check the box for yes or no. (It is this way with the rest, 65, 66, 67, 68 and 69. These cases pass to the form as an object in xml, a value that is retained in an dynamic web application.)

    Honestly I could not see any examples of this on the internet, so it makes it particularly a difficult situation.

    ——————————————————————————————

    I am also attaching a different version of the document.

    Many Thanks, Midani


  18. 04-11-2012, 11:32 AM


    #18

    Quote Originally Posted by midani

    What happens is that there is a little table on the lower left hand side of the page,…

    A Word document?


  19. 04-11-2012, 11:36 AM


    #19

    nope if you pull up that document I posted in the last post, you will see the tiny little table on the bottom left of the document.


  20. 04-11-2012, 11:41 AM


    #20

    The reason you’re getting that error (collection does not exist) is that the formfield has been deleted, probably [FONT=’Calibri’,’sans-serif’]accidentally[/FONT]. Now the code is try to access something that isn’t there.

    You’ll have to replace that file with the original. (Maybe from your email?)


Old

02-13-2014, 01:33 PM

CIF
CIF is offline

Run Time Error 4248 when opening Word Doc from Excel Windows 7 32bit Run Time Error 4248 when opening Word Doc from Excel Office 2007

Novice

Run Time Error 4248 when opening Word Doc from Excel

 

Join Date: Feb 2014

Posts: 7

CIF is on a distinguished road

Default

Run Time Error 4248 when opening Word Doc from Excel


I haved a pricing worksheet that our workgroup uses. It opens a Word Document from and Excel Worksheet and merges info from Excel to Word. It worked fine while everyone was using Office 2007. The users that have Office 2010 installed on their computers are getting a Run Time Error 4248 when they attempt to create the Word document from the Word Template. Here is a piece of the VBA code in the Excel worksheet.

Code:

Dim wrdApp As Word.Application
Set wrdApp = CreateObject("Word.Application")
Application.ScreenUpdating = False
With wrdApp
.Documents.Add Template:="G:ABPArchSpecA-OperationsGroup TemplatesQuote TemplatesMWLinearQuote.dotx"

Any help would be very much appreciated.

Reply With Quote

Old

02-15-2014, 09:15 PM

Default


That error usually occurs when you try to do something with a document that hasn’t opened. In this case, that could be because Word can’t find the referenced template. Can the affected users access the template by inserting the path as coded into Windows Explorer?

__________________
Cheers,
Paul Edstein
[Fmr MS MVP — Word]

Reply With Quote

Old

02-16-2014, 12:01 PM

CIF
CIF is offline

Run Time Error 4248 when opening Word Doc from Excel Windows 7 32bit Run Time Error 4248 when opening Word Doc from Excel Office 2007

Novice

Run Time Error 4248 when opening Word Doc from Excel

 

Join Date: Feb 2014

Posts: 7

CIF is on a distinguished road

Default


They can, but then it doesn’t populate correctly.

Reply With Quote

Old

02-16-2014, 02:25 PM

Default


Quote:

Originally Posted by CIF
View Post

They can, but then it doesn’t populate correctly.

Granted, but that wasn’t the point of the question, which was to establish that Word 2010 correctly creates a document from the template.

That being established, which code line, if any, is highlighted when you get the 4248 error?

__________________
Cheers,
Paul Edstein
[Fmr MS MVP — Word]

Reply With Quote

Old

02-16-2014, 02:56 PM

CIF
CIF is offline

Run Time Error 4248 when opening Word Doc from Excel Windows 7 32bit Run Time Error 4248 when opening Word Doc from Excel Office 2007

Novice

Run Time Error 4248 when opening Word Doc from Excel

 

Join Date: Feb 2014

Posts: 7

CIF is on a distinguished road

Default


Thanks, Paul. I’ve highlighted the line where the error occurs. It only occurs sometimes though, so it seems to be some kind of timing thing.

Code:

Sub OCLayin_CreateQuote() 
     'Collect the Needed Information
    Dim myProject, myCompanyInfoL1, myCompanyInfoL2, myCompanyInfoL3, myQuoteNumber As String 
    Dim mycustomer, mydate As String, myuser As String, myDate1 As String, myDate2 As String, myDate3 As String 
    Dim myFileName As String 
    myProject = ActiveWorkbook.Sheets("Project Setup").Range("B4") 
    myCompanyInfoL1 = ActiveWorkbook.Sheets("Project Setup").Range("B8") 
    myCompanyInfoL2 = ActiveWorkbook.Sheets("Project Setup").Range("B6") & " - " & ActiveWorkbook.Sheets("Project Setup").Range("B7") 
    myCompanyInfoL3 = ActiveWorkbook.Sheets("Project Setup").Range("B5") 
    myQuoteNumber = ActiveWorkbook.Sheets("Project Setup").Range("E4") 
    mycustomer = ActiveWorkbook.Sheets("Project Setup").Range("B6") 
    mydate = ActiveWorkbook.Sheets("Project Setup").Range("E5") 
    myuser = ActiveWorkbook.Sheets("Project Setup").Range("E7") 
    myDate1 = ActiveWorkbook.Sheets("Project Setup").Range("A45") 
    Dim wrdApp As Word.Application 
    Set wrdApp = CreateObject("Word.Application") 
    Application.ScreenUpdating = False 
    With wrdApp 
        .Documents.Add Template:="G:ABPArchSpecA-OperationsGroup TemplatesQuote TemplatesOpenCellQuote.dotx" 
        If .ActiveDocument.Bookmarks.Exists("Project") Then 
            .ActiveDocument.Bookmarks("Project").Range.Text = myProject 
        End If 
        If .ActiveDocument.Bookmarks.Exists("ToL1") Then 
            .ActiveDocument.Bookmarks("ToL1").Range.Text = myCompanyInfoL1 
        End If 
        If .ActiveDocument.Bookmarks.Exists("ToL2") Then 
            .ActiveDocument.Bookmarks("ToL2").Range.Text = myCompanyInfoL2 
        End If 
        If .ActiveDocument.Bookmarks.Exists("ToL3") Then 
            .ActiveDocument.Bookmarks("ToL3").Range.Text = myCompanyInfoL3 
        End If 
        If .ActiveDocument.Bookmarks.Exists("Date") Then 
            .ActiveDocument.Bookmarks("Date").Range.Text = mydate 
        End If 
        If .ActiveDocument.Bookmarks.Exists("User") Then 
            .ActiveDocument.Bookmarks("User").Range.Text = myuser 
        End If 
        If .ActiveDocument.Bookmarks.Exists("QuoteNo") Then 
            .ActiveDocument.Bookmarks("QuoteNo").Range.Text = myQuoteNumber 
        End If 
        If .ActiveDocument.Bookmarks.Exists("Esc") Then 
            .ActiveDocument.Bookmarks("Esc").Range.Text = myDate1 
        End If 
        If .ActiveDocument.Bookmarks.Exists("Table") Then 
            ThisWorkbook.Sheets("Quote OC Lay-in").Range("A11:H40").Copy 
            .Selection.GoTo What:=wdGoToBookmark, Name:="Table" 
            .Selection.Paste 
        End If 
        myFileName = myProject & " " & myQuoteNumber & "_" & mycustomer & " " & "Quote" & " " 
        With .Dialogs(wdDialogFileSummaryInfo) 
            .Title = myFileName 
            .Execute 
        End With 
        .Visible = True 
        .ActiveDocument.SaveAs ("G:ABPArchSpecProject FilesQuotes2014PremiumMW Open Cell" & myFileName & Format(Date, "mm-dd-yy") & ".docx") 
    End With 
    Application.CutCopyMode = False 
    Application.ScreenUpdating = True 
End Sub

Last edited by macropod; 02-16-2014 at 03:01 PM.

Reason: Added code tags & formatting

Reply With Quote

Old

02-16-2014, 03:03 PM

Default


Hi CIF,

There’s no apparent highlighting in the code you posted.

PS: When posting code, please use the code tags (which I’ve now added to your post, plus re-formatting because all of it had been lost). They’re on the ‘Go Advanced’ tab.

__________________
Cheers,
Paul Edstein
[Fmr MS MVP — Word]

Reply With Quote

Old

02-16-2014, 04:42 PM

CIF
CIF is offline

Run Time Error 4248 when opening Word Doc from Excel Windows 7 32bit Run Time Error 4248 when opening Word Doc from Excel Office 2007

Novice

Run Time Error 4248 when opening Word Doc from Excel

 

Join Date: Feb 2014

Posts: 7

CIF is on a distinguished road

Default


Thank you so much for your patience, Paul. This is my first time posting on a forum like this and I read the instructions, but I obviously did not understand them very well. The run time error occurs on this line:

If .ActiveDocument.Bookmarks.Exists(«Project») Then

Reply With Quote

Old

02-16-2014, 04:45 PM

Default


Try:

Code:

Sub OCLayin_CreateQuote()
     'Collect the Needed Information
    Dim myProject, myCompanyInfoL1, myCompanyInfoL2, myCompanyInfoL3, myQuoteNumber As String
    Dim mycustomer, mydate As String, myuser As String, myDate1 As String, myDate2 As String, myDate3 As String
    Dim myFileName As String
    Dim wrdApp As Word.Application, wrdDoc As Word.Document
    Set wrdApp = CreateObject("Word.Application")
    Application.ScreenUpdating = False
    With ActiveWorkbook.Sheets("Project Setup")
        myProject = .Range("B4").Text
        myCompanyInfoL1 = .Range("B8").Text
        myCompanyInfoL2 = .Range("B6").Text & " - " & .Range("B7").Text
        myCompanyInfoL3 = .Range("B5").Text
        myQuoteNumber = .Range("E4").Text
        mycustomer = .Range("B6").Text
        mydate = .Range("E5").Text
        myuser = .Range("E7").Text
        myDate1 = .Range("A45").Text
    End With
    Set wrdDoc = wrdApp.Documents.Add(Template:= _
    "G:ABPArchSpecA-OperationsGroup TemplatesQuote TemplatesOpenCellQuote.dotx")
    Do While wrdDoc Is Nothing: Loop
    With wrdDoc
        If .Bookmarks.Exists("Project") Then .Bookmarks("Project").Range.Text = myProject
        If .Bookmarks.Exists("ToL1") Then .Bookmarks("ToL1").Range.Text = myCompanyInfoL1
        If .Bookmarks.Exists("ToL2") Then .Bookmarks("ToL2").Range.Text = myCompanyInfoL2
        If .Bookmarks.Exists("ToL3") Then .Bookmarks("ToL3").Range.Text = myCompanyInfoL3
        If .Bookmarks.Exists("Date") Then .Bookmarks("Date").Range.Text = mydate
        If .Bookmarks.Exists("User") Then .Bookmarks("User").Range.Text = myuser
        If .Bookmarks.Exists("QuoteNo") Then .Bookmarks("QuoteNo").Range.Text = myQuoteNumber
        If .Bookmarks.Exists("Esc") Then .Bookmarks("Esc").Range.Text = myDate1
        If .Bookmarks.Exists("Table") Then
            ThisWorkbook.Sheets("Quote OC Lay-in").Range("A11:H40").Copy
            .Bookmarks("Table").Range.Paste
        End If
        myFileName = myProject & " " & myQuoteNumber & "_" & mycustomer & " " & "Quote" & " "
        With wrdApp.Dialogs(wdDialogFileSummaryInfo)
            .Title = myFileName
            .Execute
        End With
        .SaveAs2 "G:ABPArchSpecProject FilesQuotes2014PremiumMW Open Cell" _
          & myFileName & Format(Date, "mm-dd-yy") & ".docx", _
          FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
    End With
    wrdApp.Visible = True
    Set wrdDoc = Nothing: Set wrdApp = Nothing
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub

Note the revised code structure and the loop that forces Word to wait until the document being created is ready.

__________________
Cheers,
Paul Edstein
[Fmr MS MVP — Word]

Reply With Quote

Old

02-16-2014, 04:51 PM

CIF
CIF is offline

Run Time Error 4248 when opening Word Doc from Excel Windows 7 32bit Run Time Error 4248 when opening Word Doc from Excel Office 2007

Novice

Run Time Error 4248 when opening Word Doc from Excel

 

Join Date: Feb 2014

Posts: 7

CIF is on a distinguished road

Default


Thank you, Paul! I really think this is the answer. I’ll try it tomorrow morning and will let you know how it went.

Reply With Quote

Old

02-18-2014, 12:45 PM

CIF
CIF is offline

Run Time Error 4248 when opening Word Doc from Excel Windows 7 32bit Run Time Error 4248 when opening Word Doc from Excel Office 2007

Novice

Run Time Error 4248 when opening Word Doc from Excel

 

Join Date: Feb 2014

Posts: 7

CIF is on a distinguished road

Default

Applied code to one of my worksheets and now getting error message at red-type line.


Code:

 
Sub Soundsoak_CreateQuote1()
'Collect the Needed Information
Dim myProject, myCompanyInfoL1, myCompanyInfoL2, myCompanyInfoL3, myQuoteNumber As String
Dim mycustomer, mydate As String, myuser As String, myDate1 As String, myDate2 As String, myDate3 As String
Dim myquote1, myquote2, myquote3, myquote4, myquote5, myquote6, myquote7, myquote8 As String
Dim myFileName As String
Dim wrdApp As Word.Application, wrdDoc As Word.Document
Set wrdApp = CreateObject("Word.Application")
Application.ScreenUpdating = False
With ActiveWorkbook.Sheets("Project Setup")
myProject = .Range("B4").Text
myCompanyInfoL1 = .Range("B8").Text
myCompanyInfoL2 = .Range("B6").Text & " - " & .Range("B7").Text
myCompanyInfoL3 = .Range("B5").Text
myQuoteNumber = .Range("E5").Text
mycustomer = .Range("B6").Text
mydate = .Range("E6").Text
myuser = .Range("E8").Text
myDate1 = .Range("A29").Text
myDate2 = .Range("A30").Text
myDate3 = .Range("A31").Text
End With
With ActiveWorkbook.Sheets("Quote Opt 1")
myquote1 = .Range("F4").Text
myquote2 = .Range("F5").Text
myquote3 = .Range("F6").Text
myquote4 = .Range("F8").Text
myquote5 = .Range("F9").Text
myquote6 = .Range("F10").Text
myquote7 = .Range("F11").Text
myquote8 = .Range("F12").Text
End With
Set wrdDoc = wrdApp.Documents.Add(Template:="G:ABPArchSpecA-OperationsGroup TemplatesQuote TemplatesSoundsoakQuote1.dotx")
Do While wrdDoc Is Nothing: Loop
With wrdDoc
    If .Bookmarks.Exists("Project") Then .Bookmarks("Project").Range.Text = myProject
    If .Bookmarks.Exists("ToL1") Then .Bookmarks("ToL1").Range.Text = myCompanyInfoL1
    If .Bookmarks.Exists("ToL2") Then .Bookmarks("ToL2").Range.Text = myCompanyInfoL2
    If .Bookmarks.Exists("ToL3") Then .Bookmarks("ToL3").Range.Text = myCompanyInfoL3
    If .Bookmarks.Exists("Header1") Then .Bookmarks("Header1").Range.Text = myCompanyInfoL2
    If .Bookmarks.Exists("Date") Then .Bookmarks("Date").Range.Text = mydate
    If .Bookmarks.Exists("User") Then .Bookmarks("User").Range.Text = myuser
    If .Bookmarks.Exists("QuoteNo") Then .Bookmarks("QuoteNo").Range.Text = myQuoteNumber
    If .Bookmarks.Exists("Esc") Then .Bookmarks("Esc").Range.Text = myDate1
    If .Bookmarks.Exists("Esc1") Then .Bookmarks("Esc1").Range.Text = myDate1
    If .Bookmarks.Exists("Esc2") Then .Bookmarks("Esc2").Range.Text = myDate2
    If .Bookmarks.Exists("Esc3") Then .Bookmarks("Esc3").Range.Text = myDate3
    If .Bookmarks.Exists("Project1") Then .Bookmarks("Project1").Range.Text = myProject
    If .Bookmarks.Exists("QuoteNo1") Then .Bookmarks("QuoteNo1").Range.Text = myQuoteNumber
    If .Bookmarks.Exists("Q1") Then .Bookmarks("Q1").Range.Text = myquote1
    If .Bookmarks.Exists("Q2") Then .Bookmarks("Q2").Range.Text = myquote2
    If .Bookmarks.Exists("Q3") Then .Bookmarks("Q3").Range.Text = myquote3
    If .Bookmarks.Exists("Q4") Then .Bookmarks("Q4").Range.Text = myquote4
    If .Bookmarks.Exists("Q5") Then .Bookmarks("Q5").Range.Text = myquote5
    If .Bookmarks.Exists("Q6") Then .Bookmarks("Q6").Range.Text = myquote6
    If .Bookmarks.Exists("Q7") Then .Bookmarks("Q7").Range.Text = myquote7
    If .Bookmarks.Exists("Q8") Then .Bookmarks("Q8").Range.Text = myquote8
    If .Bookmarks.Exists("Table") Then
        ThisWorkbook.Sheets("Quote Opt 1").Range("Table1", LastNonBlankCell(Sheets("Quote Opt 1"))).Copy
        .Bookmarks("Table").Range.Paste
    End If
 
    myFileName = myProject & " " & myQuoteNumber & "_" & mycustomer & " " & "Quote" & " "
 
   With .Dialogs(wdDialogFileSummaryInfo)
        .Title = myFileName
        .Execute
    End With
 
    .SaveAs ("G:ABPArchSpecProject FilesQuotes2014Soundsoak" & myFileName & Format(Date, "mm-dd-yy") & ".docx")
    End With
    wrdApp.Visible = True
    Set wrdDoc = Nothing: Set wrdApp = Nothing
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub

Reply With Quote

Old

02-18-2014, 02:06 PM

Default


There’s no message with the code you’ve posted!

At a guess, I’d say you’re wanting help with this line:
With .Dialogs(wdDialogFileSummaryInfo)
Change that to:
With wrdApp.Dialogs(wdDialogFileSummaryInfo)

__________________
Cheers,
Paul Edstein
[Fmr MS MVP — Word]

Reply With Quote

Old

02-21-2014, 01:55 PM

CIF
CIF is offline

Run Time Error 4248 when opening Word Doc from Excel Windows 7 32bit Run Time Error 4248 when opening Word Doc from Excel Office 2007

Novice

Run Time Error 4248 when opening Word Doc from Excel

 

Join Date: Feb 2014

Posts: 7

CIF is on a distinguished road

Default


Thank you for all of your help! I did rewrite the code in one of my workbooks, according to our suggestion and it did not help. Now instead of getting an error message, user’s computer just sits there while it is looping through the code. When I opened his worksheet, I could not create a Word document with the macro either. It has something to do with his Reference being Microsoft Word 14.0 Object Library instead of the 12.0 Object Library I have. I’ll keep trying!

Reply With Quote

Old

02-21-2014, 02:27 PM

Default


I doubt the Word 12 & 14 references have anything to do with it. Code compiled with references to a given Word version compile with later versions also, though the reverse doesn’t work.

Since nothing’s happening, that suggests that user is unable to create the Word document. That, in turn, suggests a problem with either their user profile (e.g. permissions) or network connection.

__________________
Cheers,
Paul Edstein
[Fmr MS MVP — Word]

Reply With Quote

Содержание

  1. You receive run-time error 4248, 4605 or 5941 when you try to change properties on an unopened document in Word
  2. Symptoms
  3. Cause
  4. Workaround
  5. References
  6. You receive run-time error 4248, 4605 or 5941 when you try to change properties on an unopened document in Word
  7. Symptoms
  8. Cause
  9. Workaround
  10. References
  11. При попытке использовать VBA для изменения свойств документа появляется сообщение об ошибке при выполнении 4248, 4605 или 5941
  12. Проблема
  13. Причина
  14. Временное решение
  15. Ссылки
  16. Microsoft visual basic runtime error 4605
  17. Asked by:
  18. Question
  19. All replies
  20. Microsoft visual basic runtime error 4605
  21. Asked by:
  22. Question
  23. All replies

You receive run-time error 4248, 4605 or 5941 when you try to change properties on an unopened document in Word

Symptoms

When you try to use Microsoft Visual Basic for Applications (VBA) to change the properties of a document, you may receive one of the following error messages:

Run-time error ‘4248’:

This command is not available because no document is open.

Run-time error ‘4605’:
This method or property is not available because a document window is not active.

Run-time error ‘5941’:
The requested member of the collection does not exist.

Cause

This problem may occur if you do not have a document open, or if the document that you are referencing is not open. Word can only change the properties of an open (or visible) document.

Note These error messages may also appear if you open the document with the Visible property set to
False.

Workaround

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
For additional information about how to use the sample code that is included in this article, click the following article number to view the article in the Microsoft Knowledge Base:

290140 OFFXP: How to Run Sample Code from Knowledge Base Articles

The following sample VBA macros demonstrate how to change the value of the Title field in the
Properties dialog box. The following sample also includes code to trap the error, in case there are no documents open, and to display a message:

The following sample macro includes code that will do the following:

Trap the error, in case there are no documents open.

In the error trap, create a new document.

Resume execution at the line that caused the error.

References

For additional information about how to get help with VBA, click the following article number to view the article in the Microsoft Knowledge Base:

305326 OFFXP: Programming Resources for Visual Basic for Applications

Источник

You receive run-time error 4248, 4605 or 5941 when you try to change properties on an unopened document in Word

Symptoms

When you try to use Microsoft Visual Basic for Applications (VBA) to change the properties of a document, you may receive one of the following error messages:

Run-time error ‘4248’:

This command is not available because no document is open.

Run-time error ‘4605’:
This method or property is not available because a document window is not active.

Run-time error ‘5941’:
The requested member of the collection does not exist.

Cause

This problem may occur if you do not have a document open, or if the document that you are referencing is not open. Word can only change the properties of an open (or visible) document.

Note These error messages may also appear if you open the document with the Visible property set to
False.

Workaround

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
For additional information about how to use the sample code that is included in this article, click the following article number to view the article in the Microsoft Knowledge Base:

290140 OFFXP: How to Run Sample Code from Knowledge Base Articles

The following sample VBA macros demonstrate how to change the value of the Title field in the
Properties dialog box. The following sample also includes code to trap the error, in case there are no documents open, and to display a message:

The following sample macro includes code that will do the following:

Trap the error, in case there are no documents open.

In the error trap, create a new document.

Resume execution at the line that caused the error.

References

For additional information about how to get help with VBA, click the following article number to view the article in the Microsoft Knowledge Base:

305326 OFFXP: Programming Resources for Visual Basic for Applications

Источник

При попытке использовать VBA для изменения свойств документа появляется сообщение об ошибке при выполнении 4248, 4605 или 5941

Проблема

При попытке использовать Microsoft Visual Basic for Applications (VBA) для изменения свойств документа появляется одно из приведенных ниже сообщений об ошибке.

Ошибка при выполнении ‘4248’:

Команда недоступна, так как нет открытых документов

Ошибка при выполнении ‘4605’:
Метод или свойство недоступны, поскольку окно документа не активно

Ошибка при выполнении ‘5941’:
Запрашиваемый номер семейства не существует

Причина

Проблема возникает, когда нет открытых документов или не открыт документ, на который сделана ссылка. В программе Word предусмотрено изменение свойств только открытых документов.

Примечание. Такие сообщения об ошибках могут появиться также в том случае, если открыт документ, у которого свойство Видимый имеет значение Ложь.

Временное решение

Корпорация Microsoft предлагает примеры программного кода только для иллюстрации и не предоставляет явных или подразумеваемых гарантий относительно их корректной работы в конкретных случаях и в пользовательских приложениях. Примеры в данной статье рассчитаны на пользователя, имеющего достаточный уровень знаний соответствующего языка программирования, а также необходимых средств разработки и отладки. Специалисты служб технической поддержки Microsoft могут пояснить назначение тех или иных конструкций кода в конкретном примере, но модификация примеров и их адаптация к задачам разработчика не поддерживается. Если вам требуется дополнительная консультация по вопросам программирования, вы можете обратиться в службу консалтинга Microsoft или связаться с сертифицированными партнерами компании Microsoft. Дополнительную информацию о партнерах корпорации Microsoft можно найти в Интернете по следующему адресу:

http://www.microsoft.com/partner/referral/ За дополнительной информацией обратитесь к веб-узле корпорации Microsoft по адресу:

http://support.microsoft.com/default.aspx?scid=fh;RU;CNTACTMSЗа дополнительной информацией об использовании приведенных в этой статье примеров обратитесь к следующей статье Microsoft Knowledge Base:

290140 How to Run Sample Code from Knowledge Ниже приведен пример макроса на языке Visual Basic for Applications для изменения значения поля Заголовок в диалоговом окне Свойства. Пример содержит специальный программный код для перехвата ошибок на случай, если нет открытых документов, и вывода соответствующего сообщения.

Приведенный ниже программный код предусмотрен для выполнения следующих целей.

Перехват ошибок, если нет открытых документов

Создание нового документа при перехвате ошибки

Возобновление нормальной работы в строке, вызвавшей появление ошибки

Ссылки

Для получения помощи по работе с Visual Basic обратитесь к следующей статье Microsoft Knowledge Base:

305326 Programming Resources for Visual Basic for Applications

Источник

Microsoft visual basic runtime error 4605

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

Asked by:

Question

I wrote a script to add TAGs as comments of word document. The criteria of adding tag is based on outline numbering as document do not follow word styles, I had to use outline numbering for this purpose.

There are couple of issues I am facing.

1.) script is very slow and sometimes my word application crashes.

2.) sometimes I get a runtime error 4605 ‘This command is not available’ for line «Selection.Comments.Add Range:=Para.Range, text:=»[» & sIdLabel & sCurrentNumber & «]» & vbCrLf ‘ ID‘>»

Here is my updated code

Since you were not able to reproduce the error every time, I suspect this issue maybe relative to the context of document you were handling.

I am also trying to reproduce this issue in Word 2013 however failed. The code works well for me like figure below:

>>2.) sometimes I get a runtime error 4605 ‘This command is not available’ for line «Selection.Comments.Add Range:=Para.Range, text:=»[» & sIdLabel & sCurrentNumber & «]» & vbCrLf ‘ ID‘>»

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.

Источник

Microsoft visual basic runtime error 4605

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

Asked by:

Question

I wrote a script to add TAGs as comments of word document. The criteria of adding tag is based on outline numbering as document do not follow word styles, I had to use outline numbering for this purpose.

There are couple of issues I am facing.

1.) script is very slow and sometimes my word application crashes.

2.) sometimes I get a runtime error 4605 ‘This command is not available’ for line «Selection.Comments.Add Range:=Para.Range, text:=»[» & sIdLabel & sCurrentNumber & «]» & vbCrLf ‘ ID‘>»

Here is my updated code

Since you were not able to reproduce the error every time, I suspect this issue maybe relative to the context of document you were handling.

I am also trying to reproduce this issue in Word 2013 however failed. The code works well for me like figure below:

>>2.) sometimes I get a runtime error 4605 ‘This command is not available’ for line «Selection.Comments.Add Range:=Para.Range, text:=»[» & sIdLabel & sCurrentNumber & «]» & vbCrLf ‘ ID‘>»

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.

Источник

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Word ole error 800a175d
  • Word found unreadable content как исправить
  • Wolfenstein ii the new colossus вылетает ошибка could not write crash dump
  • Word experienced an error trying to open the file как исправить
  • Wolfenstein ii the new colossus fatal error vkcreateinstance failed with error

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии