Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Macro Open Files

Hello

I am writing a macro that prompts a user to enter two values. These values
are need to open certain files on the computer. The two values are two
folders the document is located under. I am getting the error "divide by zero"

Here's my code:

Sub Macro2()

Dim filetypenm
filetypenm = InputBox("Enter File Name you would like to compare")

Dim nm
nm = InputBox("Enter Year you would like to compare")
Application.GetOpenFilename ("""C:\Documents and Settings\All
Users\Documents\Coop Students\Small Package Rates\UPS rates\" & nm \ Air \ "
& filetypenm ")

Im sure it's just a coding problem that I can't see. Any help would be
greatly appreciated. Have been stuck for 2 days! Am making progress though
thanks to replies!

MSHO

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Macro Open Files

Try this... I think it is a problem with your quotation marks...

Sub Macro2()

Dim filetypenm As String
filetypenm = InputBox("Enter File Name you would like to compare")

Dim nm As Integer
nm = InputBox("Enter Year you would like to compare")
Application.GetOpenFilename ("C:\Documents and
Settings\AllUsers\Documents\Coop Students\Small Package Rates\UPS rates\" &
nm & "\Air\" & filetypenm)

End Sub

Also make sure you declare your variables with a type otherwise they are
variants which are very innefficient. Check out this link on declaring
variables.

http://www.cpearson.com/excel/variables.htm
--
HTH...

Jim Thomlinson


"MSHO" wrote:

Hello

I am writing a macro that prompts a user to enter two values. These values
are need to open certain files on the computer. The two values are two
folders the document is located under. I am getting the error "divide by zero"

Here's my code:

Sub Macro2()

Dim filetypenm
filetypenm = InputBox("Enter File Name you would like to compare")

Dim nm
nm = InputBox("Enter Year you would like to compare")
Application.GetOpenFilename ("""C:\Documents and Settings\All
Users\Documents\Coop Students\Small Package Rates\UPS rates\" & nm \ Air \ "
& filetypenm ")

Im sure it's just a coding problem that I can't see. Any help would be
greatly appreciated. Have been stuck for 2 days! Am making progress though
thanks to replies!

MSHO

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default Macro Open Files


Dim filetypenm as string
filetypenm = InputBox("Enter File Name you would like to compare")

Dim nm as string
nm = InputBox("Enter Year you would like to compare")

dim sTmp as string
stmp = chr(34) & "C:\Documents and Settings\All Users\"
stmp = stmp & "Documents\Coop Students\"
stmp = stmp & "Small Package Rates\UPS rates\"
stmp = stmp & nm & "\ Air \"
stmp = stmp & filetypenm & chr(34)

Application.GetOpenFilename(stmp)

Helmut Weber
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
open files run macro Steve Excel Discussion (Misc queries) 3 June 13th 08 10:43 PM
Open several text files using a macro Jade5 Excel Discussion (Misc queries) 0 October 31st 06 02:01 AM
Macro for multiple open files [email protected] Excel Discussion (Misc queries) 1 February 13th 06 03:25 AM
Macro to open *.dat files and save as .txt (comma delimited text files) [email protected] Excel Programming 2 November 30th 05 05:50 AM
Files won't open after running a macro TimZ Excel Programming 0 May 25th 05 01:58 PM


All times are GMT +1. The time now is 04:30 AM.

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

About Us

"It's about Microsoft Excel"