Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA change Word2002 (or PPT) background texture not working 1

Status
Not open for further replies.

eman6

Programmer
Joined
Dec 7, 2004
Messages
578
Location
CH
I am trying to set a background texture programmatically in Word 2002, but it's not working.

Well, after many failed attempts, I am just trying a bare hard-code. Yet, it is still not working.

Code:
    myFile = "C:\myBackgrounds\myPatternImage.jpg"
    ActiveDocument.Background.Fill.UserTextured myFile
I tried the same thing to change Word background from VB, but failed.
Actually a similar attempt with PowerPoint also failed.
When I change the background manually using the same picture as user texture, it works perfectly.

What am I missing here?

_______________________________________

Eman_2005
Technical Communicator
 
Hi
I tried your code above, and it work when I viewed the page as a web page. [ponder]
 
I get a system error at whatever view :-(

_______________________________________

Eman_2005
Technical Communicator
 
Hi
I am using Word 2000, so it must be some 'improvement' specific to W2002, I guess. When I put in a non-existent file name, I managed an out-of-memory error, but that's the best I could do for errors. :-)
 
Have you tried it with PowerPoint?
Microsoft almost always sucks with Word when they upgrade.

_______________________________________

Eman_2005
Technical Communicator
 
Hi
I tried this in Powerpoint:
ActiveWindow.Selection.SlideRange.Background.Fill.UserTextured myfile

I am not familiar with coding Powerpoint, and I found your code did not seem to suit it.
 
Well, yes of course, with PowerPoint it's not ActiveDocument, etc.

Anyway, I'll try your code.
If it did not work, I'll probably downgrade to Office 2000 :-))

Thanks for helping.

_______________________________________

Eman_2005
Technical Communicator
 
I finally had a good guess that solved the problem.
I just need to save a document with a background already set.
After that, changing the backgound programmatically would work using
Code:
ActiveDocument.Background.Fill.UserTextured myFile
Same routine on a fresh document (no background) would not work (at least with Word 2002).

_______________________________________

Eman_2005
Technical Communicator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top