A PrivateProfile String for a block of text?

L

Larry

Is there something that is the equivalent of the PrivateProfileString
statement but which, instead of just placing a string of limited length in a
setting file for later retrieval, can place an entire block of text
(preferably formatted text) for later retrieval?
 
L

Larry

I experimented using the PrivateProfileString to transfer a paragraph of
text into a settings file, but it was strictly limited in length, to 254
characters. So I'm looking for something that operates the same way as a
PrivateProfileString but that will take more characters.
 
G

Greg Maxey

Your could use Autotext:

Sub CreateEntry()
Dim oTemplate As Template
Set oTemplate = ActiveDocument.AttachedTemplate
oTemplate.AutoTextEntries.Add Name:="myText", Range:=Selection.Range
End Sub
Sub EntryAutoText()
Dim myEntry As AutoTextEntry
Dim oTemplate As Template
Set oTemplate = ActiveDocument.AttachedTemplate
For Each myEntry In oTemplate.AutoTextEntries
If myEntry.Name = "myText" Then
oTemplate.AutoTextEntries("myText").Insert Where:=Selection.Range,
RichText:=True
End If
Next myEntry
End Sub
 
A

Al Dunbar [MS-MVP]

IIRC, the function of PrivateProfileString is to manipulate .ini files. If
so, even if you could find a way to squeeze a block of formatted text into a
simple .ini text file, I suspect the application that owns the .ini file
will choke on it.

If it is your application, and if you do not need to support it on any
non-NT o/s's, have you considered using the registry instead?


/Al
 
M

mayayana

Are you talking about WritePrivateProfileString?
If so you should remove the VBScript group
from your posting. You've cross-posted to VBS and
VBA, but VBS can't use API calls.

(I think what you want is WritePrivateProfileSection,
but you may not be able to get around the 255 limit.
Those functions date to Win16. In any case, an INI
file is just for storing settings info., not long strings.
If you want to store text file sections it might make more
sense to just write a text file, or maybe write it as a
..dat file and set up your own parsing structure in the
file.)
 
J

Jezebel

Why not just write your own text file?




Larry said:
I experimented using the PrivateProfileString to transfer a paragraph of
text into a settings file, but it was strictly limited in length, to 254
characters. So I'm looking for something that operates the same way as a
PrivateProfileString but that will take more characters.
 
L

Larry

Hi Greg,

Thanks, I used your idea. The AutoText entry is created at a certain point,
from the document range of a document, whether automatically or manually.
Then, if I need it again when I'm about to paste something into a non-Word
Windows application, like a Web page, I run a .vbs file (with Winkey) which
grabs Word, opens a new document, and runs a macro that inserts the AutoText
entry, copies it, and closes the document, and then the .vbs file pastes the
clipboard contents.

In other words, with a single keystroke I access the previous clipboard
contents, bring it back into the clipboard, and paste it.

Clipboard utilities like Yankee Clipper require several steps to access the
previous clipboard contents. This does it in one stop.

Problemis, it is not elegant. I don't like having to insert and copy the
autotext instead of just magically moving it into the Clipboard somehow.
But it all happens invisibly anyway, and it accomplishes what I wanted.

Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top