|
-
Oct 15th, 2004, 08:33 PM
#1
Thread Starter
New Member
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?
-
Oct 15th, 2004, 08:44 PM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 15th, 2004, 08:52 PM
#3
Thread Starter
New Member
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.
-
Oct 16th, 2004, 12:49 PM
#4
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:
Public Sub ChangePageSetupSettings()
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.5) 'Changed from default of 1.25 to 0.5
.BottomMargin = InchesToPoints(0.5) 'Changed from default of 1.25 to 0.5
.LeftMargin = InchesToPoints(0.5) 'Changed from default of 1.25 to 0.5
.RightMargin = InchesToPoints(0.5) 'Changed from default of 1.25 to 0.5
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 18th, 2004, 08:43 PM
#5
Thread Starter
New Member
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!
-
Oct 18th, 2004, 09:16 PM
#6
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:
Public Function PrepTable()
'Formats the borders of a table
Application.Dialogs(wdDialogFormatBordersAndShading).Display
'Table properties
Application.Dialogs(wdDialogTableProperties).Display
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 18th, 2004, 09:40 PM
#7
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:
Public Function ModTable(ByVal iTableIndex As Integer) As Boolean
On Error GoTo No_Bugs
'Must have at least one table in the document
'Turns off visible table lines
Application.Documents("Document1.doc").Tables.Item(iTableIndex).Select
Selection.Tables.Item(iTableIndex).AllowAutoFit = True
Selection.Tables.Item(iTableIndex).Borders.InsideLineStyle = wdLineStyleNone
Selection.Tables.Item(iTableIndex).Borders.OutsideLineStyle = wdLineStyleNone
ModTable = True
Exit Function
No_Bugs:
ModTable = False
End Function
'Sample usage:
Private Sub Document_Open()
If ModTable(1) = False Then
Msgbox "Error modifying table properties", vbOkOnly + vbExclamation, "RobDog888 Demo"
End If
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 19th, 2004, 12:06 AM
#8
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:
Public Function SetPageSetupView() As Boolean
On Error GoTo No_Bugs
Dim oDLG As Dialog
Set oDLG = Application.Dialogs(wdDialogFilePageSetup)
With oDLG
.DefaultTab = wdDialogFilePageSetupTabMargins
.LeftMargin = InchesToPoints("0.5")
.RightMargin = InchesToPoints("0.5")
.TopMargin = InchesToPoints("0.5")
.BottomMargin = InchesToPoints("0.5")
.Orientation = wdOrientPortrait
.FooterDistance = InchesToPoints("0.5")
.HeaderDistance = InchesToPoints("0.5")
.Show 'Or .Execute to apply without showing the dialog
End With
Set oDLG = Nothing
SetPageSetupView = True
Exit Function
No_Bugs:
SetPageSetupView = False
End Function
Public Function SetPageSetupNow()
With ActiveDocument.PageSetup
.LeftMargin = InchesToPoints("0.5")
.RightMargin = InchesToPoints("0.5")
.TopMargin = InchesToPoints("0.5")
.BottomMargin = InchesToPoints("0.5")
.Orientation = wdOrientPortrait
.FooterDistance = InchesToPoints("0.5")
.HeaderDistance = InchesToPoints("0.5")
End With
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 25th, 2004, 05:28 PM
#9
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|