Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default File Path Issue in Excel 2016 for Mac

I have been using visual basic in Excel 2011 for Mac to open a file
and perform some operations on that file. The code to open the file is

Workbooks.Open Filename:= "Mac Backup:Data Files:Excel Files:Test
File.xlsx"

Mac Backup is the name of a removable drive.

The code has worked fine until I upgraded to Excel 2016 for Mac. Now
when I run the code I get the message "Sorry, we couldn't find Mac
Backup:Data Files:Excel Files:Test File.xlsx."

I have changed the colon to back slash and forward slash and still get
the error message. This same code works fine in Excel 2016 for PC
using the back slash. Apparently something has changed in the file
path structure in the Excel 2016 version for Mac. Any help would be
appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default File Path Issue in Excel 2016 for Mac

colglbo wrote:

I have been using visual basic in Excel 2011 for Mac to open a file
and perform some operations on that file. The code to open the file is

Workbooks.Open Filename:= "Mac Backup:Data Files:Excel Files:Test
File.xlsx"

Mac Backup is the name of a removable drive.

The code has worked fine until I upgraded to Excel 2016 for Mac. Now
when I run the code I get the message "Sorry, we couldn't find Mac
Backup:Data Files:Excel Files:Test File.xlsx."

I have changed the colon to back slash and forward slash and still get
the error message. This same code works fine in Excel 2016 for PC
using the back slash. Apparently something has changed in the file
path structure in the Excel 2016 version for Mac. Any help would be
appreciated.


Create a new macro-enabled (.xlsm) workbook in the same directory. Put this
code in a new module:

Sub whereAmI()
Cells(1, 1).Value = ActiveWorkbook.Path
End Sub

A1 now contains the path of the workbook. Update your existing code.

--
Are there people in your house right now you'd just love to strangle,
but can't because it's not polite to do that to company?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default File Path Issue in Excel 2016 for Mac


Sub whereAmI()
Cells(1, 1).Value = ActiveWorkbook.Path
End Sub


Just a minor point, but depending on context it's a very important point!

VBA 'best practice' suggests:

- use ActiveWorkbook only when the code is acting on or referencing a
workbook other than itself;

- use ThisWorkbook when code refs the workbook running the code.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default File Path Issue in Excel 2016 for Mac

GS wrote:

Sub whereAmI()
Cells(1, 1).Value = ActiveWorkbook.Path
End Sub


Just a minor point, but depending on context it's a very important point!

VBA 'best practice' suggests:

- use ActiveWorkbook only when the code is acting on or referencing a
workbook other than itself;

- use ThisWorkbook when code refs the workbook running the code.


Good point.

--
Don't believe everything you think.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default File Path Issue in Excel 2016 for Mac

GS wrote:

Sub whereAmI()
Cells(1, 1).Value = ActiveWorkbook.Path
End Sub


Just a minor point, but depending on context it's a very important point!

VBA 'best practice' suggests:

- use ActiveWorkbook only when the code is acting on or referencing a
workbook other than itself;

- use ThisWorkbook when code refs the workbook running the code.


Good point.


I figured since you program in other languages that you'd pick up on the 'This'
part of an object ref-ing itself!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default File Path Issue in Excel 2016 for Mac

GS wrote:

GS wrote:

Sub whereAmI()
Cells(1, 1).Value = ActiveWorkbook.Path
End Sub

Just a minor point, but depending on context it's a very important point!

VBA 'best practice' suggests:

- use ActiveWorkbook only when the code is acting on or referencing a
workbook other than itself;

- use ThisWorkbook when code refs the workbook running the code.


Good point.


I figured since you program in other languages that you'd pick up on the
'This' part of an object ref-ing itself!


I just put down the first thing that came to mind, and didn't really put any
thought into it. Since it's meant to be a one-time-only sorta thing, I'm not
terribly worried about it. (Also, I'm much more used to Activewhatever,
because my code is often run from the personal macro workbook rather than the
workbook being affected.)

--
Fear is overrated as a deterrent. Death works much better.
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default File Path Issue in Excel 2016 for Mac

On 2018-03-11 16:27:29 +0000, colglbo said:

I have been using visual basic in Excel 2011 for Mac to open a file
and perform some operations on that file. The code to open the file is

Workbooks.Open Filename:= "Mac Backup:Data Files:Excel Files:Test
File.xlsx"


The difference between Excel 2011 and Excel 2016 for Mac is that you
must now write :

Workbooks.Open Filename:= "Mac Backup/Data Files/Excel Files/TestFile.xlsx"

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default File Path Issue in Excel 2016 for Mac

On Mon, 12 Mar 2018 07:59:36 +0100, Patrick
wrote:

On 2018-03-11 16:27:29 +0000, colglbo said:

I have been using visual basic in Excel 2011 for Mac to open a file
and perform some operations on that file. The code to open the file is

Workbooks.Open Filename:= "Mac Backup:Data Files:Excel Files:Test
File.xlsx"


The difference between Excel 2011 and Excel 2016 for Mac is that you
must now write :

Workbooks.Open Filename:= "Mac Backup/Data Files/Excel Files/TestFile.xlsx"


Using the suggestion to find the path solved the problem. The required
path is

Workbooks.Open Filename:= "/Volumes/Mac Backup/Data Files/Excel
Files/TestFile.xlsx"
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default File Path Issue in Excel 2016 for Mac

colglbo wrote:
I have been using visual basic in Excel 2011 for Mac to open a file
and perform some operations on that file. The code to open the file is

Workbooks.Open Filename:= "Mac Backup:Data Files:Excel Files:Test
File.xlsx"

Mac Backup is the name of a removable drive.

The code has worked fine until I upgraded to Excel 2016 for Mac. Now
when I run the code I get the message "Sorry, we couldn't find Mac
Backup:Data Files:Excel Files:Test File.xlsx."

I have changed the colon to back slash and forward slash and still get
the error message. This same code works fine in Excel 2016 for PC
using the back slash. Apparently something has changed in the file
path structure in the Excel 2016 version for Mac. Any help would be
appreciated.

Typical M$ garbage - remove useful functionality and say nothing.

They totally diddled file open/write as follows:
ActivePrinter = "Acrobat PDFWriter on FILE:"
' Above sets printer in Excel 2003; will crash in Excel 2010.
' In "modern" defective Excel apps, following prints to default as a
' file AND prompts file name; file in printer format, NOT in PDF format.
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, _
ActivePrinter:="Acrobat PDFWriter on FILE:", PrintToFile:=True, _
Collate:=False, PrToFilename:=pPath + vNam
Kill pPath + vNam 'only PDF left

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default File Path Issue in Excel 2016 for Mac

colglbo wrote:
I have been using visual basic in Excel 2011 for Mac to open a file
and perform some operations on that file. The code to open the file is

Workbooks.Open Filename:= "Mac Backup:Data Files:Excel Files:Test
File.xlsx"

Mac Backup is the name of a removable drive.

The code has worked fine until I upgraded to Excel 2016 for Mac. Now
when I run the code I get the message "Sorry, we couldn't find Mac
Backup:Data Files:Excel Files:Test File.xlsx."

I have changed the colon to back slash and forward slash and still get
the error message. This same code works fine in Excel 2016 for PC
using the back slash. Apparently something has changed in the file
path structure in the Excel 2016 version for Mac. Any help would be
appreciated.

Typical M$ garbage - remove useful functionality and say nothing.

They totally diddled file open/write as follows:
ActivePrinter = "Acrobat PDFWriter on FILE:"
' Above sets printer in Excel 2003; will crash in Excel 2010.
' In "modern" defective Excel apps, following prints to default as a
' file AND prompts file name; file in printer format, NOT in PDF format.
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, _
ActivePrinter:="Acrobat PDFWriter on FILE:", PrintToFile:=True, _
Collate:=False, PrToFilename:=pPath + vNam
Kill pPath + vNam 'only PDF left


Note that VBA6 is used up to v2007; beginning with v2010 VBA7 is used for all
(x86/x64) editions of MSO.

FWIW
Also, beginning with v2007 Office you can generate PDFs directly using SaveAs
FixedFormat and choose XPS or PDF.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default File Path Issue in Excel 2016 for Mac

GS wrote:
colglbo wrote:
I have been using visual basic in Excel 2011 for Mac to open a file
and perform some operations on that file. The code to open the file is

Workbooks.Open Filename:= "Mac Backup:Data Files:Excel Files:Test
File.xlsx"

Mac Backup is the name of a removable drive.

The code has worked fine until I upgraded to Excel 2016 for Mac. Now
when I run the code I get the message "Sorry, we couldn't find Mac
Backup:Data Files:Excel Files:Test File.xlsx."

I have changed the colon to back slash and forward slash and still get
the error message. This same code works fine in Excel 2016 for PC
using the back slash. Apparently something has changed in the file
path structure in the Excel 2016 version for Mac. Any help would be
appreciated.

Typical M$ garbage - remove useful functionality and say nothing.

They totally diddled file open/write as follows:
ActivePrinter = "Acrobat PDFWriter on FILE:"
' Above sets printer in Excel 2003; will crash in Excel 2010.
' In "modern" defective Excel apps, following prints to default as a
' file AND prompts file name; file in printer format, NOT in PDF
format.
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, _
ActivePrinter:="Acrobat PDFWriter on FILE:", PrintToFile:=True, _
Collate:=False, PrToFilename:=pPath + vNam
Kill pPath + vNam 'only PDF left


Note that VBA6 is used up to v2007; beginning with v2010 VBA7 is used
for all (x86/x64) editions of MSO.

FWIW
Also, beginning with v2007 Office you can generate PDFs directly using
SaveAs FixedFormat and choose XPS or PDF.

USEFUL info; Thanks.
Again, un-documented change(s) that wannabe users have to guess at.
M$ s SUCH a piece..
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default File Path Issue in Excel 2016 for Mac

"Robert Baer" wrote in message

Note that VBA6 is used up to v2007; beginning with v2010 VBA7 is used
for all (x86/x64) editions of MSO.

FWIW
Also, beginning with v2007 Office you can generate PDFs directly using
SaveAs FixedFormat and choose XPS or PDF.

USEFUL info; Thanks.
Again, un-documented change(s) that wannabe users have to guess at.
M$ s SUCH a piece..


Not trying to defend MS but I don't follow why you regard the above as
'undocumented changes . . . users have to guess at'.

Before each new version the Excel team announce and discuss most planned
changes. On release a full list of changes, new features and any decremented
methods, is published on relevant MS sites and widely mirrored and discussed
elsewhere.

SaveAs PDF or XPS is hard to miss in Excel 2007 when you look at File /
SaveAs

The introduction of 64bit Office has been since its inception and continues
to be one of the most widely discussed and documented changes by MS and
elsewhere. That said if you only ever use 32bit Excel you don't need to know
anything about it. VBA7 can cater for a few special 64bit requirements
should you need them, mainly for use with APIs. Otherwise VBA7 is
effectively VBA6 even in 64bit Excel.

Peter T


  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default File Path Issue in Excel 2016 for Mac

Peter T wrote:
"Robert Baer" wrote in message

Note that VBA6 is used up to v2007; beginning with v2010 VBA7 is used
for all (x86/x64) editions of MSO.

FWIW
Also, beginning with v2007 Office you can generate PDFs directly using
SaveAs FixedFormat and choose XPS or PDF.

USEFUL info; Thanks.
Again, un-documented change(s) that wannabe users have to guess at.
M$ s SUCH a piece..


Not trying to defend MS but I don't follow why you regard the above as
'undocumented changes . . . users have to guess at'.

Before each new version the Excel team announce and discuss most planned
changes. On release a full list of changes, new features and any decremented
methods, is published on relevant MS sites and widely mirrored and discussed
elsewhere.

SaveAs PDF or XPS is hard to miss in Excel 2007 when you look at File /
SaveAs

The introduction of 64bit Office has been since its inception and continues
to be one of the most widely discussed and documented changes by MS and
elsewhere. That said if you only ever use 32bit Excel you don't need to know
anything about it. VBA7 can cater for a few special 64bit requirements
should you need them, mainly for use with APIs. Otherwise VBA7 is
effectively VBA6 even in 64bit Excel.

Peter T


Excuse me, have NEVER seen any info WRT Excel methods and/or
procedures. For all practical purposes "help" does not exist.

Furthermore, i gave code where one can PROGRAMATICALLY choose a
printer for the app, and then PROGRAMATICALLY print to it and give print
path if "ON FILE".

SaveAS etc is NOT an option when multiple instances (in a loop) ae
desired.

  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default File Path Issue in Excel 2016 for Mac


"Robert Baer" wrote in message
colglbo wrote:
I have been using visual basic in Excel 2011 for Mac to open a file
and perform some operations on that file. The code to open the file is

Workbooks.Open Filename:= "Mac Backup:Data Files:Excel Files:Test
File.xlsx"

Mac Backup is the name of a removable drive.

The code has worked fine until I upgraded to Excel 2016 for Mac. Now
when I run the code I get the message "Sorry, we couldn't find Mac
Backup:Data Files:Excel Files:Test File.xlsx."

I have changed the colon to back slash and forward slash and still get
the error message. This same code works fine in Excel 2016 for PC
using the back slash. Apparently something has changed in the file
path structure in the Excel 2016 version for Mac. Any help would be
appreciated.

Typical M$ garbage - remove useful functionality and say nothing.


Seems it was Apple that changed things -

https://macadmins.software/docs/UserContentIn2016.pdf

https://www.rondebruin.nl/mac/mac034.htm

There's a mountain of related links.

They totally diddled file open/write as follows:
ActivePrinter = "Acrobat PDFWriter on FILE:"
' Above sets printer in Excel 2003; will crash in Excel 2010.
' In "modern" defective Excel apps, following prints to default as a
' file AND prompts file name; file in printer format, NOT in PDF format.
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, _
ActivePrinter:="Acrobat PDFWriter on FILE:", PrintToFile:=True, _
Collate:=False, PrToFilename:=pPath + vNam
Kill pPath + vNam 'only PDF left


There could be several reasons. Here and when you posted your problem you
didn't give
any context. You were offered a possible solution but unless I miised it you
didn't reply.

Peter T



  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default File Path Issue in Excel 2016 for Mac

Peter T wrote:
"Robert Baer" wrote in message
colglbo wrote:
I have been using visual basic in Excel 2011 for Mac to open a file
and perform some operations on that file. The code to open the file is

Workbooks.Open Filename:= "Mac Backup:Data Files:Excel Files:Test
File.xlsx"

Mac Backup is the name of a removable drive.

The code has worked fine until I upgraded to Excel 2016 for Mac. Now
when I run the code I get the message "Sorry, we couldn't find Mac
Backup:Data Files:Excel Files:Test File.xlsx."

I have changed the colon to back slash and forward slash and still get
the error message. This same code works fine in Excel 2016 for PC
using the back slash. Apparently something has changed in the file
path structure in the Excel 2016 version for Mac. Any help would be
appreciated.

Typical M$ garbage - remove useful functionality and say nothing.


Seems it was Apple that changed things -

https://macadmins.software/docs/UserContentIn2016.pdf

https://www.rondebruin.nl/mac/mac034.htm

There's a mountain of related links.

They totally diddled file open/write as follows:
ActivePrinter = "Acrobat PDFWriter on FILE:"
' Above sets printer in Excel 2003; will crash in Excel 2010.
' In "modern" defective Excel apps, following prints to default as a
' file AND prompts file name; file in printer format, NOT in PDF format.
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, _
ActivePrinter:="Acrobat PDFWriter on FILE:", PrintToFile:=True, _
Collate:=False, PrToFilename:=pPath + vNam
Kill pPath + vNam 'only PDF left


There could be several reasons. Here and when you posted your problem you
didn't give
any context. You were offered a possible solution but unless I miised it you
didn't reply.

Peter T



So far, the ONLY solution that actually worked, was the one i posted,
and only in Excel 2003.
Certainly NOT in Excel 2010 that was purported to "do everything".



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2016 IF function wrong answer Leilan Excel Worksheet Functions 0 November 11th 16 06:32 AM
Cannot drag Excel 365 (2016) window Terry Pinnell[_4_] Excel Discussion (Misc queries) 3 November 8th 16 03:54 PM
Path Name issue for file opened from Z drive Barb Reinhardt Excel Programming 3 August 14th 08 08:05 PM
Creating Excel file that points to relative path .cub file NewUser1 Excel Programming 0 January 11th 08 03:59 PM
Formula too long - new file path is shorter than old file path - Excel 2003 Greg J Excel Worksheet Functions 1 November 22nd 06 05:16 PM


All times are GMT +1. The time now is 10:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"