Current project path to locate Word file from Excel

claven123

Board Regular
Joined
Sep 2, 2010
Messages
83
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Trying to export data from Excel to Word (using Office 365)

When I search I get millions of hits on converting excel to word..... Can't seem to find what I'm looking for.
This will be used on different computers with different users etc... so has to have a generic path to the file. With MS Access I'd use currentproject.path like the second example below.

When I use these I get the following errors.

Set doc = wd.Documents.Open(Application.CurrentProject.Path & "\TestINPORT.docx")
Run time Error 438 Object doesn't support this property or method


Set doc = wd.Documents.Open(CurrentProject.Path & "\TestINPORT.docx")

Compile error. Variable not defined
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Wanted to delete the above, since I should have included the full project, the file part above is a second portion. (I don't see a delete option)


Const FilePath As String = "C:\Users\Owner\Dropbox\Fire Department Files on Windows\Secretary\"
Dim wd As New Word.Application

Sub Button1_Click()
Dim doc As Word.Document
wd.Visible = True
Dim Active As String
Active = ThisWorkbook.Sheets(1).Range("B32").Value
Set doc = wd.Documents.Open(FilePath & "TestINPORT2.docx")
Copy2word "BookActive", Active
doc.Close
wd.Quit
End Sub

Sub Copy2word(BookMarkName As String, Text2Type As String)
wd.Selection.GoTo What:=wdGoToBookmark, Name:=BookMarkName
wd.Selection.TypeText Text2Type
End Sub

I found this on the web. It runs but nothing gets entered at the bookmark. I wonder if it would be easier/better to pull FROM within the word doc, as it will be open when I'm doing this. The above code is run from excel with word closed.
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top