Using data from an .ini file in Word

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hello all. I'm new to this group but I really hope I can get some help.

I need to add data from an .ini file and insert in the document.

I've tried this:

Content of the file User.ini:

[User]
Name = my name
Mail = me@xxxxxxxxxxxxxxxx
Fax = No fax
Tel = 0706 996106
Company= Freeducation

This is my VBA code:

Sub IniValueAtBookmark()
Dim sName As String
Dim sMail As String
Dim sFax As String
Dim sTel As String
Dim sCompany As String


'Get the values
sName = System.PrivateProfileString("C:\Documents and
Settings\Adam\Mina dokument\User.ini", "User", "Name")
sMail = System.PrivateProfileString("C:\Documents and
Settings\Adam\Mina dokument\User.ini", "User", "Mail")
sFax = System.PrivateProfileString("C:\Documents and
Settings\Adam\Mina dokument\User.ini", "User", "Fax")
sTel = System.PrivateProfileString("C:\Documents and
Settings\Adam\Mina dokument\User.ini", "User", "Tel")
sCompany = System.PrivateProfileString("C:\Documents and
Settings\Adam\Mina dokument\User.ini", "User", "Company")

End Sub

I see the value of theese expressions in the "Local" window in VBA so
this far I figure I'm right.
How do place theese values into my document? Can I let Normal.dot run
the macro and then place the values into other documents with a field
or do I have to run the macro on each document?
I've tried half a day but just go into dead ends.

What I'm trying to acheive is to have a set of standard Word templates
filling in different userdata for each user in a big company.
I tried using the Custom properties that you can set in word but they
would follow the document, not the user, right?
Hope this wasn't too messy.

Cheers
Adam, Sweden

.



Relevant Pages

  • Problem with .INI file size
    ... Problem with .INI file size. ... Private Declare Function WritePrivateProfileString Lib "kernel32" _ ... ByVal lpKeyName As Any, ByVal lpDefault As String, _ ... Dim lFileSize As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: Use XML to store settings in VB6 apps?
    ... An INI file can easily be ported over to an XML file. ... ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long ... Dim SectionsAs String, NumSections As Long, LoopSections As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: User Information
    ... > JobTitle=Junior Assistant Trainee Macro Writer ... dim i as Double 'used for counting ... dim strJobTitle as string ... then I have a macro which creates the ini file based on that table. ...
    (microsoft.public.word.general)
  • Re: Writing Efficient Code
    ... >I dont want to use a database so I have decided that an INI file would be ... >Dim file_line As String ... >Dim fStr As String ...
    (microsoft.public.vb.general.discussion)
  • Re: Output form data to a text ini file
    ... Private Sub Command2_Click ... KeyName As String, ... Dim strBuffer As String ... >I have a need to write to a ini file. ...
    (microsoft.public.access.externaldata)