PDA

View Full Version : Import word tables into access data base with the same formating



freehope
06-27-2010, 08:11 PM
Hi ,
good day

I have a problem with export tables from one word file contains separated information between 102 tables into access data base file..I tried a code when I was searching at your forum with enject it at vb editor , add microsoft access object library then call it from macro and run ,it takes about 10 minutes then creats 102 tables into access data base with ?????????? at all cells at all tables..
please be noted that I was converted that word file from older pdf after searching two dayes ago about program support my formatting language and I found finally pdfGrabber 5.0.exe.. yes the pdf file size 700 kb and after converted it to word becomes 15 mb size but no problem I approved that ..knowing my task is 200 pdf with that old version all of them i will convert it to word and export to access data base that for making a huge table with a session for searching to make it easier for voters to know thier whereabouts ,which will cast thier votes. so..I feel that I am in big trouble and realy want a proffitional one here answer those question

1\ Is there any diferrent idea with end result a huge one table in access data base??
2\ If it is Ok my Idea can any body help me with information about how can I export tables from word 2007 to access 2007 with correct way .

3\ If that happen how can I make all of these tables at access in one big table ..??cause all field at all tables at all files I have with the same fields name..natural to be in one table

please longed to know answers about my questions ASAP.
thanks,Alaa

freehope
06-28-2010, 10:06 PM
Is there any body help me ...are my questions difficult..or no one see it ..or becuase I am Arabic guy ??? wait any response with my appreciation

OBP
06-29-2010, 09:18 AM
freehope, I don't think there is a problem with you being an "Arabic guy", but there may be a problem with your data. For us to help you we would need a copy of the file, but it is against Forum ruls for you to Attach personal data on the Forum.
However if you could provide a dummy file in .txt or .rtf format instead of .docx I might be able to help. I can't work with Word 2007 files.

freehope
07-02-2010, 10:01 AM
OBP, I attached you from three dayes ago a file with rtf format with its fonts at your mail.. and no answer from you untill now..wait your response

please be noted that I can't upload any files here every time saying to me invaled ...


I used before vb at word file then added reference to access data base object library and run macro then opened access database I saw all tables but with question marks at all cells ..I tried maney other ways I feel this is the nearest one can modify it to get the correct format to Arabic tables ,I understand that code I have to inject it with function support some thing like (utf-8) or( windows ISO 1256).. so please advise me with this function which I can add it to vb code to support Arabic language

Thank
Alaa AbdelWahed
Dot Net Developer

Imdabaum
07-02-2010, 03:08 PM
Attach a dummy rtf, or word .doc/.docx.
I've never used this functionality, but I don't mind learning to help out.

freehope
07-02-2010, 08:20 PM
I attached to you through mail the word file with its font ,and attached here a dummy word file with out its font may be you can't see its arabic information cause your site doesn't support font viewer attachment so please check your mail cause the correct file and fonts in it ....
the function below which I want to add to it a function support Arabic language("utf-8" or "windows ISO 1256")

Option Explicit
Const Direct = "C:\VBAFiles\" 'full path to files
Const CsvFile = "A22.csv"
Const DataBase = "A22.mdb" ' this needs to be a valid database
Const NewTabelName = "A22Gusting"
Sub Main()
Dim i As Integer
Dim mMyData() As String
Dim mRow As Integer
Dim mColumn As Integer
Dim mClearIt As String
If Not CheckForDirectory Then Exit Sub
mClearIt = Chr(13) & Chr(7) ' the carriage return and end of cell marker
For i = 1 To ThisDocument.Tables.Count
mRow = ThisDocument.Tables(i).Rows.Count
mColumn = ThisDocument.Tables(i).Columns.Count
' this will get all text from the table and split each cell into a variable array
' it will create an extra "column" of information this is because there will be 2 carriage return and end of cell marker
mMyData = Split(ThisDocument.Tables(i).Range.Text, mClearIt)
WriteCSV mMyData, mColumn, i
Next
End Sub

Sub WriteCSV(WrtData() As String, ColCnt As Integer, BKcntr As Integer)
Dim i As Integer
Dim HldStr As String
Dim cntr As Long
Open Direct & CsvFile For Output As #1
For i = LBound(WrtData) To UBound(WrtData) Step ColCnt + 1
If i < UBound(WrtData) Then
'build string that will be written to a file
For cntr = 0 To ColCnt + 1
If cntr = 0 Then
HldStr = Chr(34) & CStr(i / (ColCnt + 1)) & Chr(34) & ","
Else
HldStr = HldStr & Chr(34) & WrtData(i + cntr - 1) & Chr(34) & ","
End If
Next
'write the file
Print #1, Left(HldStr, Len(HldStr) - 4)
HldStr = vbNullString
End If
Next
Close #1
ImportToAccess Direct & CsvFile, BKcntr
End Sub
Sub ImportToAccess(iFile As String, i As Integer)
Dim DB As New Access.Application
On Error Goto NoDB
'open database
DB.OpenCurrentDatabase Direct & DataBase
'import csv file to a new table
DB.DoCmd.TransferText acImportDelim, , NewTabelName & CStr(i), iFile, False
'close database
DB.CloseCurrentDatabase
Set DB = Nothing
On Error Goto 0
Exit Sub
NoDB:
If Err.Number = 7866 Then 'means database is not there
Err.Clear
DB.NewCurrentDatabase Direct & DataBase
Resume Next
Else
MsgBox "An Unknown Error has occured!" & Err.Description 'don't know what happened - best to stop
Err.Clear
End
End If
End Sub
Function CheckForDirectory()
Dim IsThere As String
On Error Goto Gone
CheckForDirectory = False
IsThere = Dir(Direct & "*.*", vbDirectory)
If IsThere = vbNullString Then
MkDir Left(Direct, Len(Direct) - 1)
CheckForDirectory = True
Else
CheckForDirectory = True
End If
On Error Goto 0
Exit Function
Gone:
MsgBox "An Error has occured With the Directory. Most probabal cause - Directory Does Not Exist - Cannot be created."
On Error Goto 0
Err.Clear
End Function


please advise where can I inject a function support arabic language and how ...?
thanks,wait your response v.soonly
Alaa

OBP
07-04-2010, 10:26 AM
I have not received any emails.
I am also a bit confused now.
I thought your problem was to get the data in to one table, now it appears to be a language problem?

freehope
07-04-2010, 12:41 PM
THE BASIC QUESTION IS HOW can I ADD A FUNCTION IN THIS CODE TO SUPPORT ARABIC LANGUAGE WHEN THE WORD FILE EXPORT INTO ACCESS DATABASE.
sorry for confused you

OBP
07-05-2010, 06:00 AM
I don't know how to make the Arabic Language available, normally if Office is set to Arabic it will be Arabic in Access as well. You need to look up the Help Topic
About multilingual features in Office
especially the "The font Arial Unicode"