PDA

View Full Version : [SOLVED:] Opening a word file



Chunk
04-08-2016, 11:00 AM
Hello all,

Here is my situation:

I have a userform that performs an open, find and replace, print, then close without saving procedure.

It works on my PC fine since I have all of the files coded with the exact location.
Example:

img_emblem.picture = LoadPicture("C:\DESKTOP\Test\logos\Gif\SSN-756_USS_Scranton_Crest.gif")
or

Set WB = Workbooks.Open("C:\DESKTOP\Test\HistoricalData.xlsx")

I want co-workers to be able to use the userform but have no control on where they store the files.

Is there a way to call the files in a relational way? I know this example DOESNT WORK, but here is what I tried (If the userform is in the DESKTOP directory)

Set WB = Workbooks.Open("\Test\HistoricalData.xlsx")[/

Does that make sense?

Please, any help is greatly appreciated. Thanks in advance.

Chunk

gmaxey
04-08-2016, 02:27 PM
You might try ThisDocument.Path & Application.PathSeparator & "Test\..."

gmayor
04-08-2016, 10:55 PM
If the users store the files in a manner unrelated to your path, it would probably be best to prompt for the locations and store those locations in document variables in the template that holds the userform (ThisDocument). You could then check each time it is run that those files exist at the location and if not re-prompt for them.

You could use the BrowseForFile and FileExists functions from my web site to perform the checks and prompt.

Chunk
12-27-2016, 06:58 AM
The solution was to use a shared file location.