Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-23-2015, 05:01 AM
Story11 Story11 is offline Windows GetOpenFileName Method Workaround for Excel 2011 on MAC Windows 7 64bit Windows GetOpenFileName Method Workaround for Excel 2011 on MAC Office 2013
Novice
Windows GetOpenFileName Method Workaround for Excel 2011 on MAC
 
Join Date: Jan 2015
Posts: 28
Story11 is on a distinguished road
Default

@charlesdh: Everything is messed up again. Maybe I should show you the code that worked on Windows 7, then you should help me incorporate in it the code that will make it work on both Windows and MAC.




Code:
Sub ImportWordTables()

'Imports cells (1,2), (2,2),(3,2) and (4,2) from Word document Tables 1-50

   Dim wdDoc         As Object
   Dim wdFileName    As Variant
   Dim TableNo       As Integer  'number of tables in Word doc
   Dim iTable        As Integer  'table number index
   Dim iRow          As Long     'row index in Excel
   Dim iCol          As Integer  'column index in Excel
   
   wdFileName = Application.GetOpenFilename("Word files (*.doc*),*.doc*", , _
         "Browse for file containing table to be imported")
         
   If wdFileName = False Then Exit Sub '(user cancelled import file browser)
   
   Set wdDoc = GetObject(wdFileName)   'open Word file
   
   With wdDoc
      TableNo = wdDoc.tables.Count
      If TableNo = 0 Then
         MsgBox "This document contains no tables", _
               vbExclamation, "Import Word Table"
      ElseIf TableNo > 50 Then
         TableNo = 50
      'Else TableNo is actual number of tables between 1 and 9
      End If
      
      
               Range("A1") = "S/N"
               Range("B1") = "Name"
      Range("C1") = "Age"
      Range("D1") = "Sex"
      Range("E1") = "CGPA"
      For iTable = 1 To TableNo
         With .tables(iTable)
            'copy cell contents from Word table cells to Excel cells in column B and C
            Cells(iTable + 1, "A") = iTable
            Cells(iTable + 1, "B") = WorksheetFunction.Clean(.cell(1, 2).Range.Text)
            Cells(iTable + 1, "C") = WorksheetFunction.Clean(.cell(2, 2).Range.Text)
            Cells(iTable + 1, "D") = WorksheetFunction.Clean(.cell(3, 2).Range.Text)
            Cells(iTable + 1, "E") = WorksheetFunction.Clean(.cell(4, 2).Range.Text)
         End With
         Next iTable
   End With
   
   Set wdDoc = Nothing
   
End Sub

Last edited by Story11; 01-23-2015 at 04:28 PM.
Reply With Quote
  #2  
Old 01-23-2015, 11:05 AM
charlesdh charlesdh is offline Windows GetOpenFileName Method Workaround for Excel 2011 on MAC Windows 7 32bit Windows GetOpenFileName Method Workaround for Excel 2011 on MAC Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

HI,

Sorry to say I do not know "Word". I code Excel only.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2008 vs Excel 2011 for Mac nfotx Excel 0 12-05-2014 03:48 PM
Windows GetOpenFileName Method Workaround for Excel 2011 on MAC Index Hyperlink Workaround Phil H Word VBA 9 10-30-2014 05:14 AM
Windows GetOpenFileName Method Workaround for Excel 2011 on MAC Workaround to have UserForm open from Web Link Kirsti Word VBA 11 08-23-2012 07:05 PM
Windows GetOpenFileName Method Workaround for Excel 2011 on MAC Excel 2011 can't open old Excel 98 or Excel X files FLJohnson Excel 8 05-09-2012 11:26 PM
MAC PPT 2011 compatibility with Windows stoneygeorge PowerPoint 0 08-05-2011 10:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:22 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft