ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Import files on a mac (https://www.excelbanter.com/excel-programming/321918-import-files-mac.html)

Andreas Roschger

Import files on a mac
 
Hello!

I wrote on a PC a macro to import more then one file.
Here is the code to geht the paths of the files, chosen in the dialog
window:
On th PC there were no errors
-----------------
Public

Sub DateinEinlesn()
Dim varRetVal As Variant
Dim n As Integer

varRetVal = Application.GetOpenFilename( _
FileFilter:="Text-Datein (*.txt), *.txt", _
Title:="Eine oder mehrere Dateien zum Öffnen auswählen", _
MultiSelect:=True)
MsgBox (varRetVal(1) & " " & varRetVal(2))
End Sub


----------------

now i tried to use the macro on a Mac (OSX, newest Office version),
i adopt the code = (FileFilter:="Text")

-----------------
Public

Sub DateinEinlesn()
Dim varRetVal As Variant
Dim n As Integer

varRetVal = Application.GetOpenFilename( _
FileFilter:="TEXT", _
Title:="Eine oder mehrere Dateien zum Öffnen auswählen", _
MultiSelect:=True)
MsgBox (varRetVal(1) & " " & varRetVal(2))
End Sub


----------------

But there is still an error. I think that there a problems with
"MultiSelect:=True". Without this comand its possible to import one
File.

hope someone knows how to help me
thx
Andy

JE McGimpsey

Import files on a mac
 
Multiselect is not implemented in MacXL. You'll need to loop.



In article ,
Andreas Roschger wrote:

Hello!

I wrote on a PC a macro to import more then one file.
Here is the code to geht the paths of the files, chosen in the dialog
window:
On th PC there were no errors
-----------------
Public

Sub DateinEinlesn()
Dim varRetVal As Variant
Dim n As Integer

varRetVal = Application.GetOpenFilename( _
FileFilter:="Text-Datein (*.txt), *.txt", _
Title:="Eine oder mehrere Dateien zum Öffnen auswählen", _
MultiSelect:=True)
MsgBox (varRetVal(1) & " " & varRetVal(2))
End Sub


----------------

now i tried to use the macro on a Mac (OSX, newest Office version),
i adopt the code = (FileFilter:="Text")

-----------------
Public

Sub DateinEinlesn()
Dim varRetVal As Variant
Dim n As Integer

varRetVal = Application.GetOpenFilename( _
FileFilter:="TEXT", _
Title:="Eine oder mehrere Dateien zum Öffnen auswählen", _
MultiSelect:=True)
MsgBox (varRetVal(1) & " " & varRetVal(2))
End Sub


----------------

But there is still an error. I think that there a problems with
"MultiSelect:=True". Without this comand its possible to import one
File.

hope someone knows how to help me
thx
Andy


Andreas Roschger

Import files on a mac
 
Multiselect is not implemented in MacXL. You'll need to loop.

May you give me an example of such a loop.
thx
Andy

Dave Peterson[_5_]

Import files on a mac
 
Maybe??

Sub DateinEinlesn()
Dim varRetVal As Variant
Dim n As Integer

do

varRetVal = Application.GetOpenFilename( _
FileFilter:="Text-Datein (*.txt), *.txt", _
Title:="Eine oder mehrere Dateien zum Öffnen auswählen")

if varRetVal = false then exit do

MsgBox varRetVal

loop

End Sub

Andreas Roschger wrote:

Multiselect is not implemented in MacXL. You'll need to loop.


May you give me an example of such a loop.
thx
Andy


--

Dave Peterson

Andreas Roschger

Import files on a mac
 
Sub DateinEinlesn()
Dim varRetVal As Variant
Dim n As Integer

do

varRetVal = Application.GetOpenFilename( _
FileFilter:="Text-Datein (*.txt), *.txt", _
Title:="Eine oder mehrere Dateien zum Öffnen auswählen")

if varRetVal = false then exit do

MsgBox varRetVal

loop

End Sub


thx, but the problem is, that i have to import a lot of files....
any possibility to automate this?

Andy

Dave Peterson[_5_]

Import files on a mac
 
Hmmm. I thought that this _was_ automated!

But if the filenames don't change, then maybe you could put all the names in a
worksheet and loop through that list.

From reading JE's post, it doesn't look like Mac's can get more than one file at
a time--using .getopenfilename.

I don't have any idea if there's a workaround solution on those Macs.



Andreas Roschger wrote:

Sub DateinEinlesn()
Dim varRetVal As Variant
Dim n As Integer

do

varRetVal = Application.GetOpenFilename( _
FileFilter:="Text-Datein (*.txt), *.txt", _
Title:="Eine oder mehrere Dateien zum Öffnen auswählen")

if varRetVal = false then exit do

MsgBox varRetVal

loop

End Sub


thx, but the problem is, that i have to import a lot of files....
any possibility to automate this?

Andy


--

Dave Peterson


All times are GMT +1. The time now is 07:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com