Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default need help with using VBA to access a second spreadsheet

I am writing a "client" spreadsheet using userforms. It needs to be
able to read from a "data" Workbook, and later on it will need to
write back to that workbook. I do not want to "lock" up the "data"
workbook for the entire duration. When finished, the "client" will
run with the Excel application hidden, so only the userforms will be
visible.



I am using "Application.GetOpenFilename" to find the name of the file
and storing that string in a cell.

I do not want the user to see the "data" workbook.



Problems I am experiencing:

-Opening the data workbook with the Excel application being "hidden"
the entire time

- Application.GetOpenFilename returns the FullName (as string) but
some functions want only the Name



Separate issue:

When executing the close command from the userforms, the VBA is
leaving the Excel application still running. How can I make the
actual Excel application close, unless of course the user has other
spreadsheets open?

THANKS

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 112
Default need help with using VBA to access a second spreadsheet

Hello

- Application.GetOpenFilename returns the FullName (as string) but
some functions want only the Name


Dim Fullname, JustBookName As String
Fullname = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),
*.xls")
If Fullname < False Then
JustBookName =
CreateObject("Scripting.FilesystemObject").GetFile Name(Fullname)
MsgBox JustBookName: End If

HTH
Cordially
Pascal

a écrit dans le message de news:
...
I am writing a "client" spreadsheet using userforms. It needs to be
able to read from a "data" Workbook, and later on it will need to
write back to that workbook. I do not want to "lock" up the "data"
workbook for the entire duration. When finished, the "client" will
run with the Excel application hidden, so only the userforms will be
visible.



I am using "Application.GetOpenFilename" to find the name of the file
and storing that string in a cell.

I do not want the user to see the "data" workbook.



Problems I am experiencing:

-Opening the data workbook with the Excel application being "hidden"
the entire time

- Application.GetOpenFilename returns the FullName (as string) but
some functions want only the Name



Separate issue:

When executing the close command from the userforms, the VBA is
leaving the Excel application still running. How can I make the
actual Excel application close, unless of course the user has other
spreadsheets open?

THANKS



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default need help with using VBA to access a second spreadsheet

So you're hiding the application with something like:

application.visible = false
'do something to load the userform
application.visible = true


'and
'maybe in the userform_initialize procedure???

Dim myFileName As Variant
Dim JustName As String
Dim wkbk As Workbook

myFileName = Application.GetOpenFilename
If myFileName = False Then
'user hit cancel, what happens?
Else
'keep going
JustName = Mid(myFileName, InStrRev(myFileName, "\") + 1)
Set wkbk = Workbooks.Open(Filename:=myFileName)
'do more stuff
End If

instrrev was added in xl2k. If you are using xl97, you can loop backwards
through the string.

======
While you're testing, make sure you show excel and see if there's any prompts
waiting for you to answer.

wrote:

I am writing a "client" spreadsheet using userforms. It needs to be
able to read from a "data" Workbook, and later on it will need to
write back to that workbook. I do not want to "lock" up the "data"
workbook for the entire duration. When finished, the "client" will
run with the Excel application hidden, so only the userforms will be
visible.

I am using "Application.GetOpenFilename" to find the name of the file
and storing that string in a cell.

I do not want the user to see the "data" workbook.

Problems I am experiencing:

-Opening the data workbook with the Excel application being "hidden"
the entire time

- Application.GetOpenFilename returns the FullName (as string) but
some functions want only the Name

Separate issue:

When executing the close command from the userforms, the VBA is
leaving the Excel application still running. How can I make the
actual Excel application close, unless of course the user has other
spreadsheets open?

THANKS


--

Dave Peterson
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
Run Access macro from Excel Spreadsheet Karen Excel Discussion (Misc queries) 2 January 16th 07 03:59 PM
How to access protected spreadsheet without the password? [email protected] Excel Discussion (Misc queries) 2 January 3rd 07 07:15 PM
cannot access excel spreadsheet Renn Excel Discussion (Misc queries) 2 October 5th 05 12:23 PM
Pull down cell to access n&a spreadsheet bankprofessor Excel Worksheet Functions 1 August 18th 05 06:41 PM
How protect with password the access of a spreadsheet ? Manuel Excel Discussion (Misc queries) 1 August 11th 05 07:38 PM


All times are GMT +1. The time now is 01:34 AM.

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"