Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Jun 2004
    Location
    Boston, Massachusetts, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating sequentially numbered documents - Ma (Word Mac 2001)

    Edited: <!t><!/t> and <!t><!/t> tags added around the URL to make the link live, and copied content limited to the most relevant portion. -Mod.

    Hi all,

    I'm not experienced in writing macros but I'm working on Word Purchase Order template project and need to know how to modify this code to work on the mac. Any advice would be greatly appreciated.

    Creating sequentially numbered documents (such as invoices)
    http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm

    ...
    Order = System.PrivateProfileString("C:Settings.Txt", "MacroSettings", "Order")

    If Order = "" Then
    Order = 1
    Else
    Order = Order + 1
    End If

    System.PrivateProfileString("C:Settings.txt", "MacroSettings", "Order") = Order
    ...

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Creating sequentially numbered documents - Ma (Word Mac 2001)

    First question: what have you tried so far, and what kind of errors, if any, have you received?

    The System.PrivateProfileString method is unique to Word, and lets you read settings out of Windows style "INI" files -- as illustrated in the code snippet -- as well as the Windows Registry. Does Word for Mac have this method? If not, another place that people commonly store the "last used invoice number" is in a template (sometimes shared among many users) used to generate the invoice or order form. If you search here or on the VB/VBA board for posts mentioning invoice numbers, you probably will find some useful code samples.

  3. #3
    New Lounger
    Join Date
    Jun 2004
    Location
    Boston, Massachusetts, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating sequentially numbered documents - Ma

    I'm getting a syntax error, which makes sense, because the Mac doesn't do path names like: "C://" I did test the code on a PC and it works. I was just wondering if a guru out there knew how to code this solution for the Mac...or if it was even possible...I will do a more searching, thanks...

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating sequentially numbered documents - Ma

    If you omit the path entirely, it should be stored in the Preferences folder. Would that be acceptable?

    If you want to use a specific path, it is probably something like Macintosh HD:folder1:folder2:filename

  5. #5
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating sequentially numbered documents - Ma

    Hi Judith,

    Mac's use the format:

    myhardrive:SomeFolder:SubFolder

    So try:
    <pre>System.PrivateProfileString("YourHardDrive" , "MacroSettings", "Order") = Order
    </pre>


    instead, where you'd replace YourHardDrive with ... your hard drive name.

    HTH

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Creating sequentially numbered documents - Ma

    Can you be more specific about the syntax error? Usually "syntax" refers to what VBA allows, rather than the text you give it. (If it can't understand the data, you're more likely to get a "run-time" error.) As for being a Mac VBA guru, I hope some lurk here... but it isn't something that comes up very often.

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Creating sequentially numbered documents - Ma

    Cruising around in the Object Browser looking for something else... I came across a pair of VBA functions that could be a good substitute for System.PrivateProfileString. Check out:
    <UL>GetSetting
    Returns a key setting value from an application's entry in the Windows registry or (on the Macintosh) information in the application

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •