Avatar billede per2edb Ekspert
22. november 2017 - 20:04 Der er 28 kommentarer og
3 løsninger

overføre data fra MS access 2017 til MS Project

Kan i hjælpe med at anvise hvordan man kan overføre data fra MS access 2017 til MS Project
Avatar billede terry Ekspert
22. november 2017 - 20:46 #1
Its not something I have experience with but it should be possible to import information from Access into Project

https://support.office.com/en-us/article/Export-or-import-data-to-another-file-format-6e6e581f-a580-4f04-aa87-9b6552143d9c#bm2
Avatar billede terry Ekspert
22. november 2017 - 21:04 #2
It may also be possible to connect to the Projects data file
https://www.connectionstrings.com/ms-project/
Avatar billede per2edb Ekspert
22. november 2017 - 21:28 #3
Hej Terry
Tak for svaret
Jeg havde godt set linket:
https://support.office.com/en-us/article/Export-or-import-data-to-another-file-format-6e6e581f-a580-4f04-aa87-9b6552143d9c#bm2

før men mit problem er at leg har en .accdb Access fil og mit Project 2007 kræver .mdb.
Kan det "fikses" uden at skulle save .accdb i .mdb
Avatar billede per2edb Ekspert
22. november 2017 - 22:04 #4
Jeg har også tænkt på denne  løsning :
En ProjectViewer F.Eks fra:
https://www.microsoft.com/da-dk/store/p/projectviewer/9wzdncrdfc3n

Men her kræver det at jeg via VBA kodning kan få min forespørgsel exporteret til en MPP fil i samme mappe som min App:

Altså f.eks Gantt_Produktionsplaner Forespørgsel  til en MPP fil

Kan man det?????
Avatar billede terry Ekspert
23. november 2017 - 11:02 #5
I dont have access to Project so its not easy to play around and test anything :-(

Do you have an example of the table/data you want to export to MPP file?

You could start by trying this using and MDB, just to see if its possible because if it was then you could maybe have an MDB file which you used to first insert the data you wanted to export to Project. If you see what I mean?

https://support.office.com/en-us/article/Export-or-import-data-to-another-file-format-6e6e581f-a580-4f04-aa87-9b6552143d9c#bm2
Avatar billede terry Ekspert
23. november 2017 - 11:13 #6
I can maybe download Project 2007 Standard from here, do you have any idea if its what you are using?
http://download.cnet.com/Microsoft-Office-Project-Standard-2007/3000-2076_4-10704822.html
Avatar billede terry Ekspert
23. november 2017 - 11:16 #7
seems I cant download I after all
Avatar billede per2edb Ekspert
23. november 2017 - 11:59 #8
Table:

ProduktionsplanId  Autonummerering
TaskName              Kort tekst
Duration                  Tal
Start                        Dato og klokkeslet
Finish                      Dato og klokkeslet
Avatar billede terry Ekspert
23. november 2017 - 12:07 #9
I think you should try with an MDB file, just to make sure that is possible.
Avatar billede terry Ekspert
23. november 2017 - 12:09 #10
and do you have an MPP file you could share?
Avatar billede per2edb Ekspert
23. november 2017 - 12:26 #11
Jeg har Project på en Zip fil
Kan jeg overføre den til dig
Og hvis ja hvordan
Avatar billede terry Ekspert
23. november 2017 - 13:05 #12
ekspertenATsanthell.dk
AT = @
Avatar billede terry Ekspert
26. november 2017 - 17:49 #13
I’ve now come to the conclusion that the easiest method using an .accdb database (2013, 2016, 2017 …) is to export the data from Access into a csv file and then manually import it into Project. The process is very similar to importing data from an MDB file and doesn’t really take any longer.

You can easily export the data from Access using some VBA code similar to this.

DoCmd.TransferText acExportDelim, , "tblProject", "C:\Data\Project.csv", True

I was hoping to be able to automate Project (start it using vba code) but as yet I haven’t been able to. If I could then I would be able to get Project to import the csv file automatically.

I’ll continue trying to find an easier method.
Avatar billede per2edb Ekspert
26. november 2017 - 20:18 #14
Hej  Terry

Jeg er ikke så glad for en løsning med manuel overførsel

Jeg håber det lykkes for dig at overføre automatisk

1000 tak for indsatsen indtil nu
Avatar billede per2edb Ekspert
26. november 2017 - 20:57 #15
Jeg glemt

Manuel overførsel giver vist ikke mulighed for at få opdaterede data retur fra Project. Det er vigtigt de opdaterede data kan returners tilbage til Access
Avatar billede terry Ekspert
26. november 2017 - 21:04 #16
It wasn't possible to automate it using MDB, or at least as far as I am aware, so I very much doubt its going to be possible with accdb. I've read quite a lot of information on thee web and Project 2007 seems to give many users the same problems as you have.

But I still intend to try and find a solution, just think the CSV file is the closest we can get to a usable solution.
Avatar billede per2edb Ekspert
27. november 2017 - 12:16 #17
Hi Terry

DoCmd.TransferText acExportDelim, , "Gantt_Leverancer", strPath & "\Project.csv", True

Giver denne fejl :
3441
Tekstfilspecifikationens feltseperator er magen til decimalseperatoren eller tekstafgrænseren
Avatar billede terry Ekspert
27. november 2017 - 15:19 #18
problem is because in DK the decimal separator is  a, so you need to use another field delimiter.

When you use DoCmd.TransferText to export the data you can specify a SpecificationName as second parameter.

DoCmd.TransferText acExportDelim,"SpecificationNameGoesHere" , "Gantt_Leverancer", strPath & "\Project.csv", True

Yo need to make an export specification by using the export wizard.

Right click the query and then choose Export.
Choose Text File
Alter Path/Filename
Press OK (Do not choose Export Data with ... )
Now you are in the Export Text Wizard

Choose the Advanced Button.
Now you can choose Field Delimiter. You could use ; instead of ,

Now you need to Save the Specification by press the Save As button.

The name you choose here is the same as the name you use in "SpecificationNameGoesHere"
Avatar billede terry Ekspert
27. november 2017 - 15:27 #19
If you follow the Export wizard you also get the opportunity to Save the Export Spec.
If you do this then it gets saved under External Data (menu) Saved Exports.
Now you dont need to use DoCmd.TransferText.... you can just run the Export Spec you just saved :-)
Avatar billede terry Ekspert
28. november 2017 - 15:51 #20
OK, I have now worked out how you can automate the import task.

This assumes you have a CSV file to import into Project.

You need to make a macro which imports the CSV file and save the macro giving it an appropriate name.

You need a Reference to Microsoft Project 12.0 Object Library. You can find this under Tools/References when in code view.

Now some code.

Sub RunProjectImportMacro()
Dim FileToOpen
Dim mpApp As MSProject.Application
    FileToOpen = "C:\SomePath\SomeProject.mpp"

    Set mpApp = New MSProject.Application
   
    mpApp.Visible = True
   
    mpApp.FileOpen FileToOpen
   
    mpApp.Application.Run "ImportCSV" 'Name of Macro to run
   
    mpApp.FileClose  'pjDoNotSave 'You will be prompted to save MPP file.
   
    mpApp.Quit
    Set mpApp = Nothing

End Sub

Code will probably need some changes as I dont exactly know how your using the system.
Avatar billede terry Ekspert
28. november 2017 - 15:52 #21
'pjDoNotSave means you choose not to save project
Avatar billede per2edb Ekspert
28. november 2017 - 23:26 #22
Hej

You need to make a macro which imports the CSV file and save the macro giving it an appropriate name.  < 1.  Hvor skal den oprettes og er navnet ImportCSV  ?
                                  2. Hvad skal den indeholde. Er det Sub RunProjectImportMacro()  ?
Avatar billede terry Ekspert
29. november 2017 - 09:30 #23
You create the macro in Project.

Tools, Macro, Record New Macro.

Now import the CSV file and when completed you Stop Recording in same menu.

So Access runs the macro in Project, so you dont need to do it manually.

If for some reason the import task changes then you would need to import manually, but if its the same every time then you can use the code to do it.
Avatar billede per2edb Ekspert
29. november 2017 - 11:01 #24
Jeg har placeret koderne i Access (Er det ikke der de skal placeres?)
Men:

Dim mpApp As MSProject.Application
Giver fejlen User befined type not defined
Avatar billede terry Ekspert
29. november 2017 - 14:42 #25
The macro has to be made in Project.

The code has to be in Access and needs to be changed so that the FileToOpen  is = .mpp file you want to use.

The error is probably because you need a reference to Project.

This is done in Access

"You need a Reference to Microsoft Project 12.0 Object Library. You can find this under Tools/References when in code view."
Avatar billede per2edb Ekspert
29. november 2017 - 15:18 #26
Det Virker

1000 tak for en fantastisk hjælp

Jeg afslutter her men vender måske tilbage senere (Efter Jul) når anden del af projektet skal laves - nemlig at få ændrede data fra Project ind i Access

Jeg regner med det skal laves i SQL inde i Project VBA.
Eller hvad mener du?
Avatar billede terry Ekspert
29. november 2017 - 15:57 #27
You've marked your last comment as solution to your problem ;-)

Not sure how to go about getting data from Project, maybe its also possible to go about it in a similar way. IE Create a macro in Project which exports to csv file and then import it into Access. Macro also gets executed from Access ...
Avatar billede per2edb Ekspert
29. november 2017 - 17:52 #28
Hej Igen

Ærgeligt men nu kommer der en fejl i Access når jeg anvender

Microsoft Project 12.0 Object Library

fejl 32813
Name conflicts with existing module, project or object libray
Avatar billede terry Ekspert
29. november 2017 - 19:58 #29
Had to say what problem is when I cant see what you are doing.

When do you get the error?

You can try compiling the code and if anything is wrong with references etc. then you should get an error. You can find Compile in the DEBUG menu when in code view.

And please accept one of my comments as an answer if your happy with the help you have received ;-)
Avatar billede per2edb Ekspert
29. november 2017 - 20:12 #30
Hej Terry

Fejlen opstår under opstart af access.

Jeg har debugget, men ingen fejl

Jeg har fjernet Sub RunProjectImportMacro() og alle koder heri > stadig fejl

Fejlen er der kun under opstart når Microsoft Project 12.0 Object Library aktiveres
Avatar billede terry Ekspert
29. november 2017 - 20:54 #31
In comment #26 you said
"Det Virker"

what worked here?

If there isn't a reference to  Microsoft Project 12.0 Object Library then how does it work (or not)?
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester