|
-
Jun 5th, 2005, 10:00 AM
#1
Thread Starter
Member
MSword Table
OK, here is the problem. I have an excel form where we fill out information on a per piece basis. The file is supposed named after what piece is done. I have not perfected that part but that is not my question. I am trying to figure out how to update a MS word table to represent what parts have been done (basically which files exist). For example, if item number 1A2 LS2 was done there would be a file named 1a2ls2.xls. In the MS word table I would have a column titled function and a row titled 1a2 ls2. I would need it take information from 2 specific cells from the excel file if it does excess.
-
Jun 5th, 2005, 01:39 PM
#2
Re: MSword Table
Welcome to the Forums.
Sounds like you need to list the folder contents of *.xls files into a Word table. But where are you needing the 2 cells of data from
the Excel file to go?
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 
-
Jun 5th, 2005, 02:02 PM
#3
Re: MSword Table
This should get you started.
VB Code:
'ThisDocument
Option Explicit
'Add a reference to MS Excel xx.0 Object Library
Private moApp As Excel.Application
Private Sub Document_Open()
Dim oWB As Excel.Workbook
Dim oTable As Word.Table
'ToDo: Check for Excel files in some directory.
'
'If file(s) are found then create an Excel object
Set moApp = New Excel.Application
moApp.Visible = False 'Dont know if you want to show the workbook or not.
'Open the first workbook
Set oWB = moApp.Workbooks.Open("D:\Test1.xls")
Set oTable = Documents(1).Tables(1)
'Add the Excel Cell value to a Word table cell
oTable.Cell(2, 1).Range.Text = oWB.Sheets(1).Cells(1, 1).Value
oWB.Close
Set oWB = Nothing
moApp.Quit
Set moApp = Nothing
Set oTable = Nothing
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 
-
Jun 6th, 2005, 09:20 AM
#4
Thread Starter
Member
Re: MSword Table
Hey that looks like it may work with a little tweaking.
Thanks alot Ill let ya know what the results are
-
Jun 6th, 2005, 10:42 AM
#5
Re: MSword Table
I didnt know exactly what you needed other then accessing Excel from Word and accessing the table cells.
Sure, just post back so we know if you got it solved or need more help.
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 
-
Jun 6th, 2005, 11:28 PM
#6
Re: MSword Table
xlsfile = DIR(myfilename)
will tell you if the file exists if xlsfile is not = ""
pete
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
|