Private Sub Command1_Click() 'Declare our Late Bound object(s)
Dim oWB As Object 'Create a new workbook
Dim moApp As Object
Set moApp = CreateObject("Word.Application")
Set oWB = moApp.documents.Add 'Do other stuff to it like populate cells etc. '...
Set oWB = Nothing
End Sub
i have used the above code but a default word document id not generated as soon as i press the command button.
Hi !
i have 1 more requirement in vb6.
please have a look at the code as enclosed.
i have a text file & when i click a button the contents of this text file should be automatically converted into excel file.
if i have 2 columns in the text file, then in excel sheet also i should have 2 columns.
i have done but the contents are displayed in a single column.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
you need to define the xl contants to their correct value
const xlleft = -4131
or just use the literals
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Hi!
This is w.r.t to my previous post.
i just tried converting the text file into excel file with your code.
but i got an error called input past end of file error -runtime error -62.
there are some invalid characters in the text files on line 1 or 2, which indicate end of file
to resolve this, open file for binary as 1, instead of for input, rest of the code is the same
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
I can give you the answer but I want you to try it first
First open MS Excel. Start recording a macro and then open the text file and use the Text To Columns option. Once you are done, simply copy the code to vb6 and amend it accordingly... Trust me, it is very simple. if you get stuck post your code and we will definitely help
Also search the VBF. I have given few examples on Text To Columns .
Hope this helps...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
HI!
ok i will.
I also have 1 more requirement.
i have developed a software with visual basic 6 as front end, Microsoft Sql server 2000 as backend.
I have a menu in a MDI form & it has got the listing say File-new,open,save,close etc.
all the data will be saved in proper tables.
Now i have a requirement here.
say can i add the field name as a men item from a table in the menu editor.
say i have 4 records in the table with a field called document name.
once a transaction is saved i want to add these document name in the menu editor just like how if you have 5 forms then it will show the listing of the 5 forms in the menu editor.
Hi!
this is w.r.t to our previous posts.
you have already given me the code for this.
now i have 1 more requirement here.
please find the code as enclosed.
i want to open an excel document using the late binding concept & i want to automatically print the 1st sheet with the default print settings.
how to do this in vb6.