ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Question of Import Export Files (https://www.excelbanter.com/excel-programming/301857-question-import-export-files.html)

unplugs[_12_]

Question of Import Export Files
 
Hiyee all,

Until this stage, I'm still considering a newbie in VBA althoug
I can deal with certain userform and some codes.

Anyway, I got a question.... a very basic question for export an
import files. I'm not that understand and don't know much about th
codes that can do so.

My problem is, I created 1 user form, get users entries and th
entries will then placed into excel spreadsheet respectively. Afte
that, I would want to save the spreadsheet to a text file, or wor
file. How can I do tat?

1) How the coding is if we export the data in spreadsheet to notepad ?

2) Can we specify a file name for it?

3) After we saved the file to notepad, where the file will gone? I
which location?

4) Can we auto specify a file name for the file? For example, m
spreadsheet will capture user's computer login(network), and he wil
made entries inside. After that, if he run the macro, it will save hi
file using his login name.

5) About the code that capture user's login name in networ, I saw
thread discuss about this topic yesterday, and I can't find the threa
now... Can anyone tell me where is the thread is?


Thanks a lot.... Hope it wont take ur time to answer my noo
Question... :<

Hope to hear from u all soon...

--
Message posted from http://www.ExcelForum.com


unplugs[_14_]

Question of Import Export Files
 
My data in spreadsheet are placed in column A5:F5. And I had define th
range of data as "Range", which is dynamic range that follow the user'
entries...

I had tried an example in my reference book.... but I can't figure ou
the problem... and I'm not understand those codes. I hope I can lear
from u all... Thank

--
Message posted from http://www.ExcelForum.com


unplugs[_13_]

Question of Import Export Files
 
Thanks God! About my 5th question, I had found the thread...

Anyway, i got a question about it...

' Declare for call to mpr.dll.
Declare Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" (ByVal lpName As String, _
ByVal lpUserName As String, lpnLength As Long) As Long

Const NoError = 0 'The Function call was successful

Sub GetUserName()

' Buffer size for the return string.
Const lpnLength As Integer = 255

' Get return buffer space.
Dim status As Integer

' For getting user information.
Dim lpName, lpUserName As String

' Assign the buffer size constant to lpUserName.
lpUserName = Space$(lpnLength + 1)

' Get the log-on name of the person using product.
status = WNetGetUser(lpName, lpUserName, lpnLength)

' See whether error occurred.
If status = NoError Then
' This line removes the null character. Strings in C ar
null-
' terminated. Strings in Visual Basic are no
null-terminated.
' The null character must be removed from the C strings to b
used
' cleanly in Visual Basic.
lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
Else

' An error occurred.
MsgBox "Unable to get the name."
End
End If

' Display the name of the person logged on to the machine.
MsgBox "Welcome " & lpUserName

End Sub


The above is the codes to get the user name....Anyway, can the usernam
placed in a cell? If can... How to do that? I want to placed th
username in sheet1 cell "G5".... Is there any method to do so?

and why I cannot put as:
Cells(NextRow,7) = & lpUserName
It gave me the error msg when I put "&" infront....

--
Message posted from http://www.ExcelForum.com


Dave Peterson[_3_]

Question of Import Export Files
 
Drop the & from this line:

Cells(NextRow,7) = & lpUserName

& is VBA's concatenate operator. It's used to join two pieces of text.

But you just want one.




"unplugs <" wrote:

Thanks God! About my 5th question, I had found the thread...

Anyway, i got a question about it...

' Declare for call to mpr.dll.
Declare Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" (ByVal lpName As String, _
ByVal lpUserName As String, lpnLength As Long) As Long

Const NoError = 0 'The Function call was successful

Sub GetUserName()

' Buffer size for the return string.
Const lpnLength As Integer = 255

' Get return buffer space.
Dim status As Integer

' For getting user information.
Dim lpName, lpUserName As String

' Assign the buffer size constant to lpUserName.
lpUserName = Space$(lpnLength + 1)

' Get the log-on name of the person using product.
status = WNetGetUser(lpName, lpUserName, lpnLength)

' See whether error occurred.
If status = NoError Then
' This line removes the null character. Strings in C are
null-
' terminated. Strings in Visual Basic are not
null-terminated.
' The null character must be removed from the C strings to be
used
' cleanly in Visual Basic.
lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
Else

' An error occurred.
MsgBox "Unable to get the name."
End
End If

' Display the name of the person logged on to the machine.
MsgBox "Welcome " & lpUserName

End Sub

The above is the codes to get the user name....Anyway, can the username
placed in a cell? If can... How to do that? I want to placed the
username in sheet1 cell "G5".... Is there any method to do so?

and why I cannot put as:
Cells(NextRow,7) = & lpUserName
It gave me the error msg when I put "&" infront.....

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson


unplugs[_15_]

Question of Import Export Files
 
Still waiting for the answer from somebody..... :

--
Message posted from http://www.ExcelForum.com


Dave Peterson[_3_]

Question of Import Export Files
 
http://groups.google.com/groups?selm...75E5%40msn.com

"unplugs <" wrote:

Still waiting for the answer from somebody..... :<

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson


unplugs[_17_]

Question of Import Export Files
 
Thanks Dave... U really help me a lot from the beginning until now...
:

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 09:32 AM.

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