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 SubErrHandler:
If Err <> 0 Then
'
' Display an error message.
'
MsgBox Err.Description
'
' Clear the error.
'
Err.Clear
Resume NextEnd 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 SubErrHandler:
If Err <> 0 Then
'
' Add a document.
'
Documents.Add
'
' Clear the error.
'
Err.Clear
'
' Run the code that caused the error.
'
ResumeEnd 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?
Номер ошибки: | Ошибка 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.
(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:
- 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.
- 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.
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:
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
-
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]
-
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.
-
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
-
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]
-
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]
-
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]
-
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 SubPrivate 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]
-
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 SelectSelect Case ActiveDocument.FormFields(«text68»).Result
Case «No»
ActiveDocument.FormFields(«Check17»).CheckBox.Value = True
Case «Yes»
ActiveDocument.FormFields(«Check18»).CheckBox.Value = True
End SelectSelect 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]
-
04-09-2012, 08:02 AM
#9
-
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,
-
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
-
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 DispositionsThe 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.
-
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.
-
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
-
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?
-
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.
-
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
-
04-11-2012, 11:32 AM
#18
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?
-
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.
-
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?)
-
07-10-2013, 12:16 PM
#1
Registered User
RunTIme Error 4248
Hello everyone,
I have previously posted this in this forum. http://www.mrexcel.com/forum/excel-q…ml#post3516111
My bad for not following rules before posting. Thanks to someone for letting me read the rule but that has hit me that the pressure of my problem, I forgot for a while. I thought that my respect for others had been gone for a while.Basically, I hope someone can help me figure out this problem I have in Excel.
I have this code that works fine to open ms word when I will paste data from excel. it also sets to the right position in word.
Then this code will do the copying from excel to word.
It works perfectly fine in my pc. up to now it’s all ok. but when running from my colleagues pc, it seems to miss the active document. The open ms word is working in the other pc. but the pasting part which is the second code gives us the run time error 4248 as if there is no open document. but it has succesfully opened. not sure why my code is not detecting the open word doc. and why this happens only in the other pc.
thanks in advance for the help.
Jhun
Last edited by excelaverage; 07-10-2013 at 06:24 PM.
-
07-10-2013, 12:32 PM
#2
Re: RunTIme Error 4248
Why 2 separate subs?
PS Can you please use code tags when posting code?
If posting code please use code tags, see here.
-
07-10-2013, 12:49 PM
#3
Registered User
Re: RunTIme Error 4248
Thanks Norie. I will try that one.
I can’t combine my two macros as the second macro its not consistent. The range differs depending on value.
this part is Range(«F3:J13»).Copy is a 4 row data. sometimes it’s 5, 6,7 or 8. so i use different code for them. I am not good in VB actually. My codes are mostly part by part then i just call them in single macro if I need them in sequence.Thanks really. I will try if this will work.
Jhun
-
07-10-2013, 12:51 PM
#4
Re: RunTIme Error 4248
Jhun
I can’t see why that would stop you combining the subs.
Just add code to either take user input for the no of rows to copy or to calculate the no of rows.
-
07-10-2013, 12:55 PM
#5
Re: RunTIme Error 4248
Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.
Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people’s time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it’s unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.
Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!
Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
-
07-10-2013, 12:55 PM
#6
Registered User
Re: RunTIme Error 4248
I dont know how i make my code to do in such a way that it will copy 4 rows if only 4 of them have data. 5. 6 7, and 8 accordingly. So what i did, I made different macros and then put them in 4 different buttons. The button show/hide depending on number of rows.
-
07-10-2013, 12:57 PM
#7
Registered User
Re: RunTIme Error 4248
I feel bad about this. I am so sorry. I am in panicking about this one. I should have read the rules again. I thought the other forum site is different from this one.
-
07-10-2013, 01:28 PM
#8
Registered User
Re: RunTIme Error 4248
Hi Norie.
I hope I did it right this time…
thanks very much for the reminder…
-
07-10-2013, 01:31 PM
#9
Registered User
Re: RunTIme Error 4248
Sir…
I have edited my original post. Let me know if this should be okthanks again
-
07-10-2013, 01:44 PM
#10
Re: RunTIme Error 4248
Jhun
The forums aren’t connected but both have a similar rule about cross-posting.
By the way, one reason not to cross post is because it confuses things for everybody, including yourself.
Anyway, back to the question.
It should be straightforward to add to the code to copy the correct range and run it from one button.
How is the no of rows/columns to copy determined?
Last edited by Norie; 07-10-2013 at 02:05 PM.
-
07-10-2013, 02:03 PM
#11
Registered User
Re: RunTIme Error 4248
I perfectly understand the upsetting part when cross posting.
Norie,
I have two tables.
one has the main item and I always include in copying. thats range F11:J13. F11 is header
then another table is at Capture.JPGthen another table at range F14:J18. F14 and f15 are both header too.
I put a formula in cell F20 to count the value in cell F16:F18.
If it’s 0, then it will copy only the main table and leaving the second one.if it’s 1, then it copy main table down to the first row of the second table. so that’s actually. F11:J16
if it’s 2, then F11:J17
and 3, then F11:J18.That is why i just assigned 4 buttons then i will click the one depending on number of rows to copy or 0 for the main table only.
I am glad if that can be merged into one macro only. but more than that. I am not clear why my macro is not working in other pc.
in my end, it opens the word then does the copying.
But in the other pc, it only opens the word doc but not the copying part. It gives the run time error 4288. as if the doc is not open…Thanks much sir…
-
07-10-2013, 02:04 PM
#12
Registered User
Re: RunTIme Error 4248
I perfectly understand the upsetting part when cross posting.
Norie,
I have two tables.
one has the main item and I always include in copying. thats range F11:J13. F11 is header
then another table is at Attachment 249288then another table at range F14:J18. F14 and f15 are both header too.
I put a formula in cell F20 to count the value in cell F16:F18.
If it’s 0, then it will copy only the main table and leaving the second one.if it’s 1, then it copy main table down to the first row of the second table. so that’s actually. F11:J16
if it’s 2, then F11:J17
and 3, then F11:J18.That is why i just assigned 4 buttons then i will click the one depending on number of rows to copy or 0 for the main table only.
I am glad if that can be merged into one macro only. but more than that. I am not clear why my macro is not working in other pc.
in my end, it opens the word then does the copying.
But in the other pc, it only opens the word doc but not the copying part. It gives the run time error 4248. as if the doc is not open…by the way the error points to this part of code.
Thanks much sir…
Last edited by excelaverage; 07-10-2013 at 02:09 PM.
-
07-10-2013, 02:14 PM
#13
Re: RunTIme Error 4248
There could be a number of reasons that the 2nd code isn’t working.
I’d probably go for Word not actually being open when it runs.
As for deciding what to copy, that is straightforward if you have things set up as you describe.
-
07-10-2013, 02:19 PM
#14
Registered User
Re: RunTIme Error 4248
how do I do that? I am ok with Word not being opened but pasting is actually happening. is that what you meant Norie? Then I will just manually open the word doc later on to check?
-
07-10-2013, 02:23 PM
#15
Re: RunTIme Error 4248
Sorry I don’t know what you mean.
For the second code you posted Word has to be open, otherrwise there’s nothing for GetObject to get.
-
07-10-2013, 02:57 PM
#16
Registered User
Re: RunTIme Error 4248
sorry to confuse you.
In your previous answer, you said «I’d probably go for Word not actually being open when it runs.». I thought if I want to, I can let excel paste into word without actually opening it. like a background thing that is processing. And I also thought, then I can just open the word doc later on to see if it has really pasted on.
But the code is already working. together with the rows being adjusted based on cell value.
Really nice…
I envy your coding skills. Wish I could learn that too.
Thanks really from the bottom of my heart. Save another tons of work in my job.Jhun here…
-
07-10-2013, 03:03 PM
#17
Re: RunTIme Error 4248
Jhun
No problem.
-
07-10-2013, 06:07 PM
#18
Registered User
Re: RunTIme Error 4248
Norie,
may i have a follow up question.
on this codeI only have F20 as my criteria.
What I have either F20 or F47. If F20 has value either 0,1,2,3,4 then it will do as above.
How do I edit such that if F20 is blank and the populated cell is F47 with either 0,1,2,3,4 also. it will also do as above. This time using different rows.I just edited the above code. It’s just the nested if that I can’t figure out.
here is the code I am trying.
I can’t get the other IF to work. It’s just always the first if that copies to word.
Please help again.
Thanks
-
07-10-2013, 06:18 PM
#19
Re: RunTIme Error 4248
-
07-10-2013, 06:22 PM
#20
Registered User
Re: RunTIme Error 4248
wow that was fast.
I also did edit your previous code into this.it also worked.
this is finally solved Sir
Thanks Thanks… For everyone to see…
Hi Guys,
I have a template which is there in Templates folder of C:Program files(x86)Microsoft OfficeTemplatesLondon folder.
Now when I click the icon from word ribbon which i have created to initialize the signature template from the London folder, it should pop up Signature user form with word document in background so the user can enter their details.
But, I receive a run time error ‘4248’, this command is not available because no document is open.
i found few articles where they have written code to trap the error and then initialize the template.below is one of the code form the source link WD2000: Error Message: «Run-time error ‘4248’; ‘This command is not available because no document is open.'»
Code:
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
'Execute the code that caused the error.
Resume
End If
End Sub
One more code is updated for the same
Code:
F
Function IsWordDocOpen(sWordDocFullName As String) as Boolean
Dim wdApp as Object ' Late Binding - who cares?
Dim wdDoc as Object
IsWordDocOpen = False
On Error Resume Next
'- try to get Word application
Set wdApp = GetObject(, "Word.Application")
If Err.Number = 4248 Then ' Word is not open
Exit Function
End If
On Error GoTo 0
For Each wdDoc in wdApp.Documents
If wddoc.FullName = sWordDocFullName Then
IsWordDocOpen = True
Exit Function
End If
Next
End Function
Now, I would like to clarify where to place this code in word document ?
Is it in ThisDocument of the Word document or in Modules of template macro code ?
Also please confirm whether the above code will initialize the template user form after the error is trapped and cleared ?