English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

3 answers

i dont know

2006-08-01 02:11:40 · answer #1 · answered by viswanathansri 2 · 0 1

Actually if uou create any empty document with the right extension the program (word, excel) will see it and open it but if you need the actual inside formatting then

1. An easy way is to keep a new empty doc created by word/excel and then copy that with a new name under vb when you need to open a new one.
say c:\ YOUR APPLICATION FOLDER\empty.doc

and under vb

sub createnewempty(newfilename as string)
filecopy "empty.doc", newfilename
end sub

2. A more sophisticated way is to 'READ' the above into a byte array and then actually produce it each time.


Here is an actual example below

'PROGRAM CREATE EMPTY.RTF

Private Sub Command1_Click()
'RTF EXAMPLE
'Here for an actual empty file copied with a hex editor
'Byte values are in hex two digits e.g. 7B is the first value
'followed by 5C etc.

a$ = "7B5C727466315C616E73"
a$=a$+"695C616E736963706731"
a$=a$+"3235325C64656666305C"
a$=a$+"6465666C616E67313033
a$=a$+"367B5C666F6E7474626C"
a$=a$+"7B5C66305C6673776973"
a$=a$+"735C6663686172736574"
a$=a$+"3136317B5C2A5C666E61"
a$=a$+"6D6520417269616C3B7D"
a$=a$+"417269616C2047726565"
a$=a$+"6B3B7D7D0D0A7B5C2A5C"
a$=a$+"67656E657261746F7220"
a$=a$+"4D736674656469742035"
a$=a$+"2E34312E31352E313530"
a$=a$+"373B7D5C766965776B69"
a$=a$+"6E64345C7563315C7061"
a$=a$+"72645C6C616E67313033"
a$=a$+"325C66305C667332305C"
a$=a$+"7061720D0A7D0D0A00"

Open "c:\t1.rtf" For Output As 1

'Take all hex values above
For t = 1 To Len(a$) Step 2
'Convert hex to actual bytes
h$ = "&H" + Mid$(a$, t, 2)
'get the actual value in decimal
v = Val(h$)
'print the actual character to the file
Print #1, Chr$(v);
Next t

Close 1

'Try the file with wordpad
Shell "write c:\t1.rtf", vbMaximizedFocus
End Sub

PS. I used a HEX EDITOR to grab the byte values of this file but you can do the same with a small program as shown below:

'PROGRAM GET THE BYTES OF THE EMPTY.RTF without a hex editor
'set the alfa string with length of one character only
dim alfa as string *1

'get the file length of a file that you wish to copy
f=filelen(anempty.doc)

'open the file for byte access with length of read =1 (byte)
open "anempty.doc" for random as 1 LEN =1

'For all the bytes of the file
for t=1 to f
'get byte ''t'' and store to character alfa
get #1,t,alfa
'add it in your string
h$=hex$(asc(alfa))
if len(h$)=1 then h$="0"+h$ ' Make this into two digits
a$=a$+h$
next t
close 1

open "hexvalues.txt" for output as 1
print #1,a$
close 1
shell "notepad hexvalues.txt",vbmaximizedfocus

'Now you can use this string inside your previous program

I HOPE THE ABOVE HELPS

Stefanos

2006-08-04 22:56:47 · answer #2 · answered by smendonis 1 · 0 0

San Read it and learn

http://search.msn.co.uk/results.aspx?q=How+to+create+temp+Excel&geovar=56&FORM=REDIR

2006-08-01 23:02:22 · answer #3 · answered by Joe_Young 6 · 0 0

fedest.com, questions and answers