Results 1 to 9 of 9

Thread: VB, Visual Studio, Office 2003

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Location
    On the dancefloor
    Posts
    4

    VB, Visual Studio, Office 2003

    I’ve inherited an array of software installations on my workstation (at work).
    My OS is Windows 2000, and the installed apps include:

    Office 2003 Standard Edition, which comes with VB 6.3 and the dialog constants (wdDialogTableWrapping, wdDialogToolsAutoCorrect, etc) (which are called namespaces, I think, in Visual Studio .net lingo).
    VB 6.0 Working Model,
    Microsoft Visual C++ Professional Edition,
    MSDN Library for Visual Studio 6.0installed (VB 6.3 is reached only through Office 2003 apps).

    The working model of VB has no built-in help, so using this is really frustrating, I cannot F1 anything. Even help for VB 6.3 has empty placholders for the graphics (links work, but graphic words at the top of each help page are blank squares).

    My job is to customize Word 2003—to create a template, with limited number of styles (ProtectStyles), and any automation that will ensure corporate docs coming from different places retain some common layout. Definitely I’ll have lots of macros. And I assume they need to be written in VB 6.3 (what’s the difference from .net?)

    Given the tools I have, rely a lot on online info, user groups (MS or not).

    I’d like to use Visual Studio, but wonder which version I can/should use (and I need to figure out how to attach Visual Studio project to a Word docuemnt template). Also, how does one attache get the wdDialog library to Visual Studio. Does anyone have a descriptive compendium of the arguments for WdWordDialog constants?

    I have books: Writing Word Macros by OReilly, VB 6 (Visual Studio series) by Deitel and Deitel. None addresses this. The online tutorials from MSFT for creating windows Applications with VB use unidentifiable versions of Windows, VisualStudio, .Net servers—is there a decipherable compendium available for using (backward compatible Office 2003 tools? Where else to go to find help to walk me through creating custom interface for Word 2003?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Welcome to the Forums.

    If all you need to do is create a Word template then you dont
    need VB. You can do it from Words VBA Editor depending on the
    document's requirements. The macro recorder is your best friend
    in VBA. Record a macro of a certain task you want to do. Then
    stop recording and view the code it produces in the module. Make
    sure you save the macro code in the new template and not the
    Normal.dot template.

    First thing to do is to create the template and define the layout.
    Then add the controls needed (if any). Then code controls.

    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Location
    On the dancefloor
    Posts
    4

    Thanks Rob, but I need to create an input form..and I'm wondering how to lock things

    Hi Rob,

    I've recorded macros before, but I want to make some input forms for adding standard data to title/header/footer (name of project, book number, title of book, etc)

    Also, I want to lock the stylesheet, or have a tool to run through the doc and do a cleanup.

    Given that I want to go beyond simple macro recording, I started looking around and that got me lost.

    For example, I'd like to change the values on some of the default dialogs (if this is possible) or to create a new tab (or disable other tabs on the tabbed Properties dialog.

    My "research" has brought me to this site. I don't even know what all I have available to me with the application set I currently have.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    To start you should define your required requirements and then
    take them one at a time.

    Yes, it is possible to change the values on the dialogs. You can
    view the code necessary by recording a macro, calling the dialog,
    changing some of the values, and then clicking ok.

    So here is code to change values on the page setup dialog
    window. Code from recorded macro.


    VB Code:
    1. Public Sub ChangePageSetupSettings()
    2.  
    3.     With ActiveDocument.Styles(wdStyleNormal).Font
    4.         If .NameFarEast = .NameAscii Then
    5.             .NameAscii = ""
    6.         End If
    7.         .NameFarEast = ""
    8.     End With
    9.     With ActiveDocument.PageSetup
    10.         .LineNumbering.Active = False
    11.         .Orientation = wdOrientPortrait
    12.         .TopMargin = InchesToPoints(0.5) 'Changed from default of 1.25 to 0.5
    13.         .BottomMargin = InchesToPoints(0.5) 'Changed from default of 1.25 to 0.5
    14.         .LeftMargin = InchesToPoints(0.5) 'Changed from default of 1.25 to 0.5
    15.         .RightMargin = InchesToPoints(0.5) 'Changed from default of 1.25 to 0.5
    16.         .Gutter = InchesToPoints(0)
    17.         .HeaderDistance = InchesToPoints(0.5)
    18.         .FooterDistance = InchesToPoints(0.5)
    19.         .PageWidth = InchesToPoints(8.5)
    20.         .PageHeight = InchesToPoints(11)
    21.         .FirstPageTray = wdPrinterDefaultBin
    22.         .OtherPagesTray = wdPrinterDefaultBin
    23.         .SectionStart = wdSectionNewPage
    24.         .OddAndEvenPagesHeaderFooter = False
    25.         .DifferentFirstPageHeaderFooter = False
    26.         .VerticalAlignment = wdAlignVerticalTop
    27.         .SuppressEndnotes = False
    28.         .MirrorMargins = False
    29.         .TwoPagesOnOne = False
    30.         .BookFoldPrinting = False
    31.         .BookFoldRevPrinting = False
    32.         .BookFoldPrintingSheets = 1
    33.         .GutterPos = wdGutterPosLeft
    34.     End With
    35.    
    36. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Location
    On the dancefloor
    Posts
    4

    Recorded macro vs wdDialogFilePageSetup

    RobDog888,

    Thanks! Your example is what I'd get if I were using the macro recorder.

    However, advice from MVP people indicate its "far more efficient to use the wdWordDiaglogs." So I've been looking for the treasure map that identifies how to use these wdDialogs.

    Here's an example: I've created a TableFix macro (using record macro method) that autosizes the table to contents, sets the cells in a table to TableCell style, the first column in same table to TableCellBold, the first row to TableHeading as well as Heading Rows Repeat. Sad thing is, the last setting (HRR) is a toggle when using Record Macro, so I need verify each table in a doc by navigating into the menu to see whether that toggle is set or unset by virtue of running the macro. It looks like I can set most of these using wdDialogTableAutoFormat, but I need the Rosetta stone for arguments HeadingRows,FirstColumn--and where are the settings for the Table Properties dialog (allow <num> spacing between cells, don't permit cell to break across pages)?

    A big want: I want to change/add labels on a predefined dialog--or if that's disallowed, then replace a predefined dialog with my custom dialog--without losing performance.

    Where would I find the treasuremap (online download, training, MS press book, or combination thereof) for using wdDialog constants (i.e., are the arguments Boolean, text, numeric, what's the defualt settings, etc).

    A good roadmap would be for you to replace the code sample you provided with equivalent in wdDialog code.

    What does it mean when wdDialogSearch has no arguments? What's the purpose of the arugment "Category" in the wdDialogTableFormatCell?

    I appreciate your help!

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Well, from M$:
    It's not very efficient to use a Dialog object to return or
    change a value for a dialog box when you can return or change it
    using a property or method. Also, in most, if not all, cases, when
    VBA code is used in place of accessing the Dialog object, code is
    simpler and shorter.
    So with that being said, I think you would want to use the
    properties of your table to make any modifications instead of
    using a dialog as long as the table has been created. If its a
    table to be created, then it may be better to setup the table
    dialog first then create the new tables.


    VB Code:
    1. Public Function PrepTable()
    2.    
    3.     'Formats the borders of a table
    4.     Application.Dialogs(wdDialogFormatBordersAndShading).Display
    5.     'Table properties
    6.     Application.Dialogs(wdDialogTableProperties).Display
    7.    
    8. End Function
    Which one is the one you need or are they both wrong? Or is this
    for a already existing table?


    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    This will turn off the visible lines in a table. Just pass the table index
    in the document you want to modify. Change the document index
    to your document name.

    Note: Not from recorded macro


    VB Code:
    1. Public Function ModTable(ByVal iTableIndex As Integer) As Boolean
    2.    
    3.     On Error GoTo No_Bugs
    4.    
    5.     'Must have at least one table in the document
    6.     'Turns off visible table lines
    7.     Application.Documents("Document1.doc").Tables.Item(iTableIndex).Select
    8.     Selection.Tables.Item(iTableIndex).AllowAutoFit = True
    9.     Selection.Tables.Item(iTableIndex).Borders.InsideLineStyle = wdLineStyleNone
    10.     Selection.Tables.Item(iTableIndex).Borders.OutsideLineStyle = wdLineStyleNone
    11.     ModTable = True
    12.     Exit Function
    13.    
    14. No_Bugs:
    15.     ModTable = False
    16. End Function
    17.  
    18. 'Sample usage:
    19. Private Sub Document_Open()
    20.     If ModTable(1) = False Then
    21.         Msgbox "Error modifying table properties", vbOkOnly + vbExclamation, "RobDog888 Demo"
    22.     End If
    23. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Two more for you. First one is using a dialog to do the page setup.
    The second is accessing the properties directly. You can choose
    GUI vs. Performance.

    No recorded macros were harmed or used in the making of this code.


    VB Code:
    1. Public Function SetPageSetupView() As Boolean
    2.    
    3.     On Error GoTo No_Bugs
    4.    
    5.     Dim oDLG As Dialog
    6.    
    7.     Set oDLG = Application.Dialogs(wdDialogFilePageSetup)
    8.     With oDLG
    9.         .DefaultTab = wdDialogFilePageSetupTabMargins
    10.         .LeftMargin = InchesToPoints("0.5")
    11.         .RightMargin = InchesToPoints("0.5")
    12.         .TopMargin = InchesToPoints("0.5")
    13.         .BottomMargin = InchesToPoints("0.5")
    14.         .Orientation = wdOrientPortrait
    15.         .FooterDistance = InchesToPoints("0.5")
    16.         .HeaderDistance = InchesToPoints("0.5")
    17.         .Show 'Or .Execute to apply without showing the dialog
    18.     End With
    19.     Set oDLG = Nothing
    20.     SetPageSetupView = True
    21.     Exit Function
    22.    
    23. No_Bugs:
    24.     SetPageSetupView = False
    25. End Function
    26.  
    27.  
    28. Public Function SetPageSetupNow()
    29.    
    30.     With ActiveDocument.PageSetup
    31.         .LeftMargin = InchesToPoints("0.5")
    32.         .RightMargin = InchesToPoints("0.5")
    33.         .TopMargin = InchesToPoints("0.5")
    34.         .BottomMargin = InchesToPoints("0.5")
    35.         .Orientation = wdOrientPortrait
    36.         .FooterDistance = InchesToPoints("0.5")
    37.         .HeaderDistance = InchesToPoints("0.5")
    38.     End With
    39.    
    40. End Function
    VB/Outlook Guru™!

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Location
    On the dancefloor
    Posts
    4

    Doc Properties (5 tabs)

    Hi Rob,

    I've tried 2 specific requirements, maybe you can help.

    Requirement #1:

    Create input fields for complex, repeating values:

    How to set the input fields in File Properties (Doc Summary values, and 2 entries on Custom tab)...the fields I want to put in Title, Footer, text are Doc Type, Product ID, Doc ID (tied to Product ID, with different suffix, correlates 1:1 with Doc Type). When I use the Macro Wizard with File|Properties to set values, all that displays in VB Editor is wdDocProperties.Show, not even which TAB. What's the VB Editor call-out for Summary(Category), Custom (myCustomName, myCustomNameVal).

    where
    myCustomName = DocumentType
    myCustomNameVal = (User Guide, Config Guide, or Test Report)

    DocType = (UserGuide=232, ConfigGuide=532, TestReport=832)
    So, for
    ProductID = 1234-5678-123
    UserGuide=1234-5678-232
    ConfigGuide=1234-5678-532
    TestReport=1234-5678-832

    Requirement #2:

    How can I insert a numbered item that is tied to the heading (i.e., Section 4.7.1.2.5 has a table, 4-23, with 15 items in it. I want to call out item 9 (so ComponentID 4-15.9--and this ID must be unique). I tried inventing a new Label, but when I try to insert this new label in a table, Word makes a decsion and jumpt to a blank paragraph above the table, prepared to insert a table caption.

    If I use SEQ for the .9, how can I automatically add the number for the table such that I can insert a cross reference to the item number in text. Also, since it's a numbered Item, the dropdown list in the Xref includes every possible numbered "thing"...is there any way to limit the X-ref list to one type: Component ID, so I don't have to view numbered lists, headings, tables, figures...EVERYTHING with a number?

Posting Permissions

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



Click Here to Expand Forum to Full Width