opening word file in vba on mac
opening word file in vba on mac
opening word file in vba on mac
opening word file in vba on mac
opening word file in vba on mac
opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac
opening word file in vba on mac opening word file in vba on mac
opening word file in vba on mac
Go Back  Xtreme Visual Basic Talk > > > > opening word file in vba on mac


Reply
 
Thread Tools Display Modes
  #1  
Old 06-14-2018, 01:30 AM
hunterbr hunterbr is offline
Newcomer
 
Join Date: Nov 2007
Posts: 7
Default opening word file in vba on mac


I am running excel 2016 on a mac(OS10.13.5) and have a problem with this VBA code:

Code:
Sub TestFile1()
Dim filestring As String
Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("Word.application")
FilePath = "/Volumes/256SSD/How to do stuff/new docs/Test doc.docx"
Set wdDoc = wdApp.Documents.Open(FileName:=FilePath)
wdApp.Visible = True
End Sub
The first time I run it, at the "Set wdApp=" line, the first word screen which asks for file input comes up. If I wait for several seconds, eventually the Test doc.docx opens.
Then I quit the word window and rerun the code. This time I get an "Automation error" with the first word screen asking for input remaining on the screen. If I quit word and clear the automation error and rerun the code it is ok (except for the first word screen coming up again).
I can repeat this cycle several times and eventually get an "out of memory" error and excel becomes unresponsive and I have to force quit excel to gain control.
Can anyone help with this please?
Reply With Quote
  #2  
Old 06-14-2018, 09:53 PM
Kluz's Avatar
Kluzopening word file in vba on mac Kluz is offline
Sapience.Aquire

Super Moderator
* Expert *
 
Join Date: Oct 2003
Location: Lake Bluff, Ill., U.S.
Posts: 3,466
Default

I don't have a mac to test this on, but I'll give it a shot.
It's good programming practice to Set all object variables that have been assigned an object value be Set = Nothing before the end of the Sub.
You might also look into Referencing the Microsoft Word Object Library in order to take advantage of Early Binding instead of the Late Binding you are currently using if Mac Office supports this).
__________________
No the other right mouse click
Reply With Quote
  #3  
Old 06-16-2018, 08:01 PM
hunterbr hunterbr is offline
Newcomer
 
Join Date: Nov 2007
Posts: 7
Default

It seems part of the problem was that "Show word documentation when opening word" was selected in Word's Preferences. I deselected this and it prevented the gallery from showing first.

Now I have modified the code to:

Code:
Sub buttontest1()
Dim objdoc As Object

With CreateObject("word.application")
Set objdoc = .documents.Open("/Volumes/256SSD/word docs/shortcut keys.docx")
End With
Set objdoc = Nothing
End Sub

But the reult is still the same: first time runs ok, quit word; next time "automation error"and blank word doc opens. Clear error, quit word, rerun, ok. Then quit word, run again, "out of memory error".

Is there a way out of this?
Reply With Quote
  #4  
Old 06-16-2018, 10:19 PM
Kluz's Avatar
Kluzopening word file in vba on mac Kluz is offline
Sapience.Aquire

Super Moderator
* Expert *
 
Join Date: Oct 2003
Location: Lake Bluff, Ill., U.S.
Posts: 3,466
Default

I've had the "out of memory" error on a PC as well. It would happen on some comps and not on others. Never could find an MS explanation or a cure even when the problem comps had their memory upgraded.
Does Mac have the PC equivalent of the PC's Task Manager? Where you could monitor your memory usage and active applications.
__________________
No the other right mouse click
Reply With Quote
Reply

Tags
word, screen, dim, code, excel, quit, error, set, doc.docx, time, automation, rerun, eventually, input, wddoc, object, wdapp, vba, file, remaining, running, mac, coming, repeat, gain


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
opening word file in vba on mac
opening word file in vba on mac
opening word file in vba on mac opening word file in vba on mac
opening word file in vba on mac
opening word file in vba on mac
opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac opening word file in vba on mac
opening word file in vba on mac
opening word file in vba on mac
 
opening word file in vba on mac
opening word file in vba on mac
 
-->