Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 04-26-2020, 01:24 PM
marceepoo marceepoo is offline Is it possible to use a .txt file to populate a msgbox prompt field Windows 7 64bit Is it possible to use a .txt file to populate a msgbox prompt field Office 2010 64bit
Novice
Is it possible to use a .txt file to populate a msgbox prompt field
 
Join Date: Sep 2012
Posts: 22
marceepoo is on a distinguished road
Default

Dear Graham:

While doing some research to understand how and why your solution worked, I came across the following:

The "FreeFile function" page (located at: FreeFile function (Visual Basic for Applications) | Microsoft Docs), which led me to:
1. The "Open statement" page (located at: 404 - Content Not Found | Microsoft Docs and
2. The "Writing data to files" page (located at: Writing data to files (VBA) | Microsoft Docs)
which contained two information items that perplex me:

The first item was an admonition not to use the Open statement in Word Vba:
Note[:] The Open statement should not be used to open an application's
own file types. For example, don't use Open to open a Word document,
a Microsoft Excel spreadsheet, or a Microsoft Access database.
Doing so will cause loss of file integrity and file corruption.
But my subsequent use of Word's macro recorder (View, Record macro ...), seemed to recommend that I may or should use the Open statement:
Code:
Sub subOpenExistingWordDoc()
        '
            ChangeFileOpenDirectory _
                "E:\DirName"
            Documents.Open FileName:="Filename.docx", ConfirmConversions:=False, _
                 ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
                PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
                WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:="", _
                DocumentDirection:=wdLeftToRight
        End Sub
I think that I am missing some idea that has a role in why you used the FreeFile function in your solution.
I recognize that you were using the Open statement for reading as distinguished from writing.
But I also suspect that I am missing something central.
I would appreciate it if you could point me to where I could get some insight into what the admonition not to use the Open statement is all about.


The second item that perplexed me on "Writing data to files" page was the table stating that I could write to a file using either the "Print #" or "Write #" statements.

I could not find pages where Microsoft explains how each of those statements operate, e.g., the syntax and any related information, particularly for the "Print #" statement, which I have never seen used in VBA for the purpose of recording information to a file.
Do you know where I could find more info about the "Print #" and "Write #" statements, to which that page was referring?

If I shouldn't be asking you this type of question, or if you don't have time to waste on these things, please forgive me for asking.

Thanks again the help you gave me.

Marc
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Make 2013 Populate To Field abraxis Outlook 2 08-10-2018 06:41 AM
populate list with unique field value on repeated field value sukusnairss Excel 1 04-03-2018 11:47 PM
Have Text Entered in Content Control / PreDefined Field Populate Field in Footer bzowk Word 1 04-14-2016 11:50 AM
Is it possible to use a .txt file to populate a msgbox prompt field Prompt a macro to run when opening a specific file type gmanword Word VBA 5 11-30-2013 02:55 PM
Openin File in Use Locks PC Up, No Read only Prompt barkster Office 0 06-08-2010 01:22 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft