2016年9月23日星期五

[Anwsered] Creating a Macro to import an arbitrary file into excell.

Creating a Macro to import an arbitrary file into excell.

I'm trying to make a macro that will import an arbitrary file into excel.
I can make one that repeatedly imports a specific file, but I want to find a way to make the file location a parameter that I can change.  I would ultimately like the macro to import the text file, give the excel workbook the same name as the text file,
and then save it in a similar location.  Any advice as to how I would go about this would be much appreciated.

Solutions to the Problem Creating a Macro to import an arbitrary file into excell.

Download SmartPCFixer to Fix It (Free)

Here's the command you want to work with:
Application.GetOpenFilename
and here is the help system's discussion:


Application.GetOpenFilename Method


Displays the standard Open dialog box and gets a file name from the user without actually opening any files.
Syntax
expression.GetOpenFilename(FileFilter,FilterIndex,
Title, ButtonText, MultiSelect)
expression   A variable that represents anApplication object.
Parameters


Name
Required/Optional
Data Type
Description

FileFilter
Optional
Variant
A string specifying file filtering criteria.

FilterIndex
Optional
Variant
Specifies the index numbers of the default file filtering criteria, from 1 to the number of filters specified inFileFilter.
If this argument is omitted or greater than the number of filters present, the first file filter is used.

Title
Optional
Variant
Specifies the title of the dialog box.
If this argument is omitted, the title is "Open."

ButtonText
Optional
Variant
Macintosh only.

MultiSelect
Optional
Variant
True to allow multiple file names to be selected.
False to allow only one file name to be selected.
The default value isFalse.


Return Value
Variant
Remarks
This string passed in the FileFilter argument consists of pairs of file filter strings followed by the MS-DOS wildcard file filter specification, with each part and each pair separated by commas.
Each separate pair is listed in theFiles
of type drop-down list box.
For example, the following string specifies two file filters—text and addin: "Text Files (*.txt),*.txt,Add-In Files (*.xla),*.xla".
To use multiple MS-DOS wildcard expressions for a single file filter type, separate the wildcard expressions with semicolons; for example, "Visual Basic Files (*.bas; *.txt),*.bas;*.txt".
If FileFilter is omitted, this argument defaults to "All Files (*.*),*.*".
This method returns the selected file name or the name entered by the user.
The returned name may include a path specification.
IfMultiSelect is
True, the return value is an array of the selected file names (even if only one filename is selected).
ReturnsFalse if the user cancels the dialog box.
This method may change the current drive or folder.
 
Example
This example displays the Open dialog box, with the file filter set to text files.
If the user chooses a file name, the code displays that file name in a message box.


Visual Basic for Applications

fileToOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt")If fileToOpen <> False Then MsgBox "Open " & fileToOpenEnd If



If this answer solves your problem, please check, Mark as Answered.
If this answer helps, please click the Vote as Helpful button.
Cheers Shane Devenshire

  1. Access the files on your computer via MY COMPUTER
  2. Under the C: drive, access the WINDOWS folder
  3. Select the SOFTWARE DISTRIBUTION folder, followed by the DOWNLOAD folder.
  4. Delete any files within this download folder.
  5. If you are unable to delete these files, open the command prompt (CMD) as the administrator, and type "net stop wuauserv" into the CMD prompt window. Press ENTER. This should allow you to delete the files from step 4.
  6. Once the files are deleted, open and run the CMD as the administrator and type "wuauclt.exe /updatenow". Press ENTER.

Another Safe way to Fix the Problem: Creating a Macro to import an arbitrary file into excell.:

How to Fix Creating a Macro to import an arbitrary file into excell. with SmartPCFixer?

1. Download Error Fixer . Install it on your computer.  Click Scan, and it will perform a scan for your computer. The junk files will be shown in the list.

2. After the scan is done, you can see the errors and problems which need to be repaired.

3. When the Fixing part is done, your computer has been speeded up and the errors have been fixed


Related: How Can You Update & Download NVidia 6100, 6800 GS/XT Display Driver v.260.89 WHQL,Where to Download NVidia GeForce 8800 GT WHQL-certified driver v.196.21,How to Update & Download NVidia GeForce Go 7400 Display Driver v.260.19.12,[Solved] Download NVidia GeForce GTX 460M Driver v.331.82,Download NVidia Quadro Plex Model IV VGA Driver v.304.43 Certified,Way to Download RealTek RTL8100C(L) Driver v.5.01,Way to Download RealTek RTL8100E Drivers v.694,Way to Update & Download RealTek RTL8101L Auto Installation Program v.6.110 driver,Method to Update & Download RealTek RTL8111G PXE and RPL ROM code v.2.58 driver,How to Update & Download RealTek RTL8411B(N) Driver v.10.003,Best Way to Update & Download ASUS A53SV nVidia Graphics Driver v.8.17.12.6686,Method to Herunterladen ASUS K75VJ Intel Rapid Storage Technology Treiber v.11.6.0.1030,How Can You Update & Download ASUS CG8580 Intel Chipset Driver v.9.3.0.1019,Method to Update & Download ASUS K41VD Intel INF Update Driver v.9.1.1.1015,Way to Update & Download ASUS Pro70T NB Probe v.3.0.0026 driver
Read More: [Anwsered] control doc not responding>,[Solved] Core framework files are not trusted error,Troubleshooting:Creating more than one Index in Word 2010,How to Resolve - Cursor Jumps while typing - Windows 7?,How Can I Fix - copy range to row below based on cell value from formula?,Closing Internet Explorer causes error,Compare 2 Tables and Calculate the PROFIT Faster,Computer goes to Windows Boot Manager after Start,Connect to one of my network computer remotely when don't allow exception box Marked,computer locking up randomly

没有评论:

发表评论